Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

horizontal buttons - Css

Featured Replies

hi, im kinda new to this. im just working on my first site and are having some problems making a horizontal panel of buttons for the top of my site using css rules eg a:hover , etc .

 

i have set my links into a <ul>. the problem i am getting is that i would like the whole of the button's background to change when the mouse is over the button, also have all of the button be clickable instead of just the text inside it.

 

so far i have managed to get the text colour and the background just behind the text to change colour, and can only get it in a vertical men bar.

 

thanks in advance

 

dave

changing the elements within the ul to display:inline should make it horizontal

to make the overall background change you need to add something like this to the css

 

a:hover ul.myclassname{

background-color:red;

}

 

this only works if you give the holding ul a class of myclassname or whatever you prefer - what this is saying is when you hover over an A, make any UL with a classname of myclassname, have background color of red

does that make any sense?

  • Author
changing the elements within the ul to display:inline should make it horizontal

to make the overall background change you need to add something like this to the css

 

a:hover ul.myclassname{

background-color:red;

}

 

this only works if you give the holding ul a class of myclassname or whatever you prefer - what this is saying is when you hover over an A, make any UL with a classname of myclassname, have background color of red

does that make any sense?

 

yeah i think so, am at work so can only print this out and try it when i get home :)

 

the only other way os to just make it a rollover which i was trying not to do, but hey, if i have to i have to

 

ta for the reply

the only other way os to just make it a rollover which i was trying not to do, but hey, if i have to i have to

There is another way, but it's probably not as good practice as Womble's suggestion.

You can add padding to the <li> elements in your css eg:

a:hover li.myclassname {
padding:5px 10px;
}

This will make the background area appear larger around the text.

  • Author
There is another way, but it's probably not as good practice as Womble's suggestion.

You can add padding to the <li> elements in your css eg:

a:hover li.myclassname {
padding:5px 10px;
}

This will make the background area appear larger around the text.

 

ok thanks, prob not best practice as you say :) , but maybe could do something with it.

ta for your reply

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.