Results 1 to 22 of 22

Thread: Easy question but difficult answer

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Arrow Easy question but difficult answer

    If I wanted to use CSS to create a menu similar to the popup menus on VBF that change the backcolor when you mouseover then and not just the link portion?

    I dont need it to popup, only look and when mouseovered act the same.
    I went through the css code but I cant get it to work at all.

    Here is an example.

    Thanks
    Attached Images Attached Images  
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: Easy question but difficult answer

    make ur links a list and in css for the link hover property do ul: alink hover thingy and pick the color cause the ul is the background while the li are the links

  3. #3

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy question but difficult answer

    But that only changes the background color of the text in the link and not the entire cell.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Easy question but difficult answer

    style the li:hover to be the same as your a:hover......

    Here's what I have on my site:
    Code:
    #pages li {list-style-type: square;}
    #pages .page_item:hover {list-style-type: square; color: #800000; }
    #pages .page_item:hover ul {list-style-type: circle; color: #ffffff; }
    #pages li .page_item{list-style-type: circle; margin-left: 5px; list-style-position: inside; border: 0px; border-bottom: 1px solid #800000; border-left: 1px solid #800000;}
    #pages li .page_item a {text-decoration: none;}
    #pages li .page_item:hover{list-style-type: disc; color: #800000;}
    the #pages is the ID of a ul list where pages for the site are...
    Each li item is classed with "page_item" so in the CSS I used #pages .page_item:hover to get a rollover effect. The key is the first two items. I don't change the background color in mine, but if you do, you may want to make the background-color of your a tags transparent in the list. It's easier that way. Then you can change the background-color of the li tag w/o needing to also do the a tag.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Easy question but difficult answer

    You need to use the onmouseover and onmouseout events and change the className atrribute of the element. This is quite simple:
    Code:
    <html>
        <head>
    	<title>Highlight a Div</title>
    	<style type="text/css">
    	    .highlight {
    		background-color: gray;
    	    }
    
    	    .borderDiv {
    		border: 5px solid black;
    	    }
    	</style>
    	<script type="text/javascript">
    	    <!--
    	    
    	    function toggleHighlight(element)
    	    {    
    		if (element.className.search(/highlight/) != -1) // check if the highlight style has already been applied
    		{
    		    element.className = element.className.replace(/highlight/, ''); // if it has, remove it
    		}
    		else // if it hasn't add it
    		{
    		    if (element.className.length > 0) 
    		    {
    			element.className = element.className + ' highlight'; // add it to the original class name	
    		    } 
    		    else 
    		    {
    			element.className = 'hightlight';
    		    }
    		}
    	    }
        
    	    //-->
    	</script>
        </head>
        <body>
    	<div class="borderDiv" onmouseover="toggleHighlight(this);" onmouseout="toggleHighlight(this);">
    	    <a href="http://www.vbforums.com/">A Link To VBForums</a>
    	</div>
        </body>
    </html>
    Example here: http://adam.codedv.com/examples/div_highlight.html
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy question but difficult answer

    Yes, like that Adam but its using JS. Isnt that bad in case some users dont have JS enabled? I thought it could be done completely without using JS?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Easy question but difficult answer

    It took me time to reply - most CSS browser have JS enabled. But the user can disable it. In which case the CSS only one which tg shows is the better option as it accomodates the lowest common denominator.

    I've modified the example so it uses tg's suggestion too. You may want to fiddle the CSS to get rid of the bullet point though.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: Easy question but difficult answer

    Like this?
    Code:
    <html>
    <head>
    <title></title>
    <style type="text/css">
    td
    {
    	font-size: 16px;
    	width:130px;
    	border:1px solid blue
    }
    td a
    {
    	text-decoration: none;
    	color:blue;
    	background-color: white;
    	display:block;
    }
    td a:hover
    {
    	background-color: blue;
    	color: white;
    }
    </style>
    </head>
    <body>
    
    <table>
    	<tr>
    		<td>
    			<a href="">Link</a>
    		</td>
    	</tr>
    	<tr>
    		<td>
    			<a href="">Link</a>
    		</td>
    	</tr>
    	<tr>
    		<td>
    			<a href="">Link</a>
    		</td>
    	</tr>
    	<tr>
    		<td>
    			<a href="">Link</a>
    		</td>
    	</tr>
    	<tr>
    		<td>
    			<a href="">Link</a>
    		</td>
    	</tr>
    </table>
    
    </body>
    </html>
    {yak}

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Easy question but difficult answer

    yak - that's only going to change the a tag.... not the cell as the user hovers over it.
    the td:hover also needs to be styled... and if it's the same as the a: hover.... you can do it like this:
    Code:
    td:hover, td a:hover
    {
    	background-color: blue;
    	color: white;
    }
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: Easy question but difficult answer

    is this wat ur trying to do?

    www.ninjanutz.t35.com -> my link buttons

  11. #11

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy question but difficult answer

    I get a 404 error.

    @TG, the "td:hover" is a hover event for the table data tag or is it just missing the a tag in there?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: Easy question but difficult answer

    Well maybe I misunderstood, I thought he wanted to change the entire background color of the cell, that the link is in? Like this:
    Attached Images Attached Images  
    {yak}

  13. #13
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Easy question but difficult answer

    yak -yeees.... which is why you have to add :hover to the td cell.... otherwise, if you only :hove the a tag, and it doesn't span the entire width of the cell..... you get a partialy filled in cell....

    @RD - yes, it's the hover for the table cell... as I was just telling yak, the width of the a tag is going to vary according to it's contents, so unless the a tag spans the entire width of the table cell, you'll get a partial fill in the cell..... Alternatively I think you can set the width:100% for the a tag in a td cell in your menu.... then you shouldn't need the td:hover.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  14. #14
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: Easy question but difficult answer

    Hmmmmm mine seems to be coloring the entire cell, only tested in FF though...
    {yak}

  15. #15

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy question but difficult answer

    Thanks guys, hopefully I can get some time to complete the menu by tomorrow. I am glad to hear that I can have an all css menu with rollover effects just like the quick links popup menu without the popup.

    So as long as I place the custom links and tds before the general ones they should get applied correctly.

    I'll be back when I can to give an update and ask any other questions I may have implementing this.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: Easy question but difficult answer


  17. #17

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy question but difficult answer

    Yes, like that. I see you dont use any tables, only DIVs. Are tables outdated now? Should I switch to DIVs and ordered lists for this?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18
    Hyperactive Member ninjanutz's Avatar
    Join Date
    Jun 2005
    Location
    Bayside
    Posts
    256

    Re: Easy question but difficult answer

    i tried tables...got tired of em divs seem to be easier

  19. #19

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Easy question but difficult answer

    But DIVs are newer and should I be using them?

    Also, using tgs example, how do I get different styles for different TDs and if I switch to DIVs then what do I do?

    Code:
    td:hover, td a:hover
    {
    	background-color: blue;
    	color: white;
    }
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #20
    Lively Member {yak}'s Avatar
    Join Date
    Aug 2005
    Posts
    119

    Re: Easy question but difficult answer

    I only used tables because I remember a thread back, and thought you were using tables. Although divs are better than tables, in some situations. Some people will think they are doing well, by changing their tables to divs, then they have 30 divs instead of 30 tables, in that case, divs are not better. But back to topic, with a menu, i'd use a list..I believe techgnome's css is assumed using a list.

    Good luck;
    {yak}

  21. #21
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Easy question but difficult answer

    @RD... Take a look at my site ( http://tannagh.com ) is the menu on the left there what you are looking for? (the rollover is sublte, but noticable.).... You may want to use ul/li tags (that's what mine is made of)... after all that's what a menu is -- a list of options.

    As for using tables, with CSS gaining, it's become the conventional wisdom that tables should be used for showing tablular data, not controling layout.

    I've found the following resources helpful:
    http://www.positioniseverything.net/
    http://www.csszengarden.com/
    http://www.alistapart.com/

    and the webdeveloper extention for Firefox...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  22. #22
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Easy question but difficult answer

    Just set display:block for the "a" elements. Makes them fill out the entire available space.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width