Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS how to place an image to the right of variable width text on roll over?

Tags:

html

css

I have a menu of text with variable widths eg:

Home
Services
About Us
Contact

How can I position an image to the right of the different width text on hover in css? Is it possible without using a fixed width?

Home
Services •
About Us
Contact

or

Home
Services
About Us
Contact •
like image 482
williamsongibson Avatar asked Nov 24 '25 01:11

williamsongibson


1 Answers

Live demo http://tinkerbin.com/RrRtqfVf

Do this one

HTML

<ul>
  <li>Hello</li>
  <li>Hello</li>
  <li>Hello</li>
  <li>Hello</li>
  <li>Hello</li>
  <li>Hello</li>
  <li>Hello</li>

</ul>

Css

    ul{
list-style:none;

}
li{
position:relative;
  float:left;
  clear:left;
  margin-top:10px;
}
li:hover:after{
content:'';
  background:red;
  position:absolute;
  right:-20px;
  top:5px;
  width:10px;
  height:10px;
}

Demo

like image 50
Rohit Azad Malik Avatar answered Nov 25 '25 15:11

Rohit Azad Malik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!