简体   繁体   English

正确对齐li元素

[英]Proper aligning li elements

I'm trying to put each li element in its own row. 我试图将每个li元素放在自己的行中。 Each li element contains a img on left-hand and some text as a description. 每个li元素的左侧都包含一个img,并包含一些文本作为说明。 One more requirement, everything should be responsive. 另一个要求是,一切都应该响应。 Right now, written code is responsive enough but it does not put each li element separately. 目前,书面代码已足够灵敏,但并未将每个li元素分别放置。 Here's code: 这是代码:

 .portfolio-images { margin: auto auto auto 30px; } .portfolio-image { float: left; margin: auto 10px 10px 5px; } #portfolio-images ul { list-style: none; } .portfolio-images li { display: block; } 
 <div class="container-fluid" id="portfolio-images"> <ul> <li> <img class="portfolio-image img-responsive" src="http://i64.tinypic.com/2ltg2h4.jpg"> <h3>kitty</h3> <p>ipsum kitty itsum sit on the fur watching the grass. grass shine in sun burning bright light on the buildings. fan schemrring in the light. house painted yellow, black and red.</p> </li> <li> <img src="http://i64.tinypic.com/2ltg2h4.jpg" alt="devops" class="portfolio-image img-responsive"> <h3>kitty</h3> <p>ipsum kitty itsum sit on the fur watching the grass. grass shine in sun burning bright light on the buildings. fan schemrring in the light. house painted yellow, black and red.</p> </li> <li> <img src="http://i64.tinypic.com/2ltg2h4.jpg" alt="devops" class="portfolio-image img-responsive"> <h3>kitty</h3> <p>ipsum kitty itsum sit on the fur watching the grass. grass shine in sun burning bright light on the buildings. fan schemrring in the light. house painted yellow, black and red.</p> </li> </ul> </div> 

Please help with this. 请帮忙。

You haven't cleared the float of .portfolio-images . 您尚未清除.portfolio-images的浮动。 There are many ways to do so, in this case I've used overflow: auto on the .item class, which I've applied to all li tags: 这样做的方法很多 ,在这种情况下,我使用了overflow: auto .item类上的.item ,已将其应用于所有li标签:

 .item { overflow: auto; } .portfolio-images { margin: auto auto auto 30px; } .portfolio-image { float: left; margin: auto 10px 10px 5px; } #portfolio-images ul { list-style: none; } .portfolio-images li { display: block; } 
 <div class="container-fluid" id="portfolio-images"> <ul> <li class="item"> <img class="portfolio-image img-responsive" src="http://i64.tinypic.com/2ltg2h4.jpg"> <h3>kitty</h3> <p>ipsum kitty itsum sit on the fur watching the grass. grass shine in sun burning bright light on the buildings. fan schemrring in the light. house painted yellow, black and red.</p> </li> <li class="item"> <img src="http://i64.tinypic.com/2ltg2h4.jpg" alt="devops" class="portfolio-image img-responsive"> <h3>kitty</h3> <p>ipsum kitty itsum sit on the fur watching the grass. grass shine in sun burning bright light on the buildings. fan schemrring in the light. house painted yellow, black and red.</p> </li> <li class="item"> <img src="http://i64.tinypic.com/2ltg2h4.jpg" alt="devops" class="portfolio-image img-responsive"> <h3>kitty</h3> <p>ipsum kitty itsum sit on the fur watching the grass. grass shine in sun burning bright light on the buildings. fan schemrring in the light. house painted yellow, black and red.</p> </li> </ul> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM