html - Padding on anchor included in list doesn't resize the list item's height -


i know, why setting vertical padding on anchor nested in unordered link doesn't resize list items height. can see on jsfiddle, tabs bigger ul component, overlaps div underneath.

i expect li , ul gets high content, div paragraph gets shifted down.

html

<div class="tab-row">     <ul>         <li>             <a href="#"><span>tab 1</span></a>         </li>         <li>             <a href="#"><span>tab 2</span></a>         </li>     </ul> </div>     <div class="tab-content">         <p>lorem ipsum dolor sit amet, consectetuer adipiscing elit. nulla tincidunt semper quam. suspendisse potenti. donec adipiscing consequat erat.              morbi semper, libero vel pulvinar tincidunt, lorem lorem scelerisque felis, sed tempor dolor dolor non felis. quisque eu est.              quisque blandit, pede non commodo convallis, purus elit pellentesque neque, in tempor libero dolor quis quam. quisque eros. vivamus porttitor.              aenean quis odio. cras commodo risus ac est. fusce molestie, lacus @ sagittis fermentum, dolor eros ultrices tellus, ac sollicitudin pede risus.</p>     </div> </div> 

css

ul {     margin: 0;     padding: 0;     list-style-type: none; } .tab-row li {     display: inline; } .tab-row li {     border: 1px solid #cccccc;     padding: 10px;     text-decoration: none; } .tab-content {     border1px solid #cccccc; } .tab-content p {     text-align: justify;     margin: 10px; } 

because you're adding padding inline element. add:

.tab-row li {    display: inline-block; } 

or float left.

why setting padding on inline element doesn't work here?

you can have left , right padding inline elements. specs. every property should applied "in line", line being defined line-height property of parent element. read more in article.

why floating left works too?

floats turn block element.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -