I have structure like this
<div class='myClass'>
<ul>
<li>
<a href="myfile.html">My link</a>
</li>
</ul>
</div>
My li
has a fixed with.
But a
text is not always equal to li
width
So the click able area is less than li
.
I tried to fix it by increasing the width of the a
but it is not working.
How can I achieve it.
I am using the following css
.tooltipinner ul {
list-style-type: none;
margin: 0;
overflow-y: auto;
padding: 0;
width: 305px;
}
.tooltipinner ul li {
background-color: #BBAEA5;
background-image: url("../../Images/UIFiles/Menu/SubmenuBg.jpg");
background-position: left top;
background-repeat: repeat-x;
border-top: 1px solid #C1BFBD;
color: #FFFFFF;
cursor: pointer;
float: left;
font-size: 12px;
padding-bottom: 4px;
padding-left: 5px;
padding-top: 4px;
width: 199px;
}
.tooltipinner ul li:hover {
background-color: #BBAEA5;
background-image: url("../../Images/UIFiles/Menu/SubmenuBgHover.jpg");
background-position: left bottom;
background-repeat: repeat-x;
border-top: 1px solid #C1BFBD;
cursor: pointer;
float: left;
padding-left: 5px;
}
.tooltipinner ul li a {
color: #000000;
font-size: 12px;
font-weight: 400;
text-decoration: none;
}
.tooltipinner ul li a:link {
color: #000000;
min-width: 200px;
text-decoration: none;
}
I was also trying to put a div
inside a
but block
element can not be placed inside a
.
How can I fixed this.
Here is a fiddle
http://jsfiddle.net/qry45/2/
http://jsfiddle.net/qry45/4/
You need to make your anchor display: block or display: inline-block; and then it will accept the width and height values.
An anchor is an inline element by default so you can't add dimensions to it unless you change its display property.
To change the font size in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-size. HTML5 do not support the <font> tag, so the CSS style is used to add font size.
Something like this in your CSS:
.myClass li a {
width: 100%;
}
Block elements can be placed inside inline elements (<a>
, <span>
, etc.) if you're using the HTML5 doctype, and if you set display: block;
on the <a>
element:
.myClass li a {
display: block;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With