所以我有这个列表,里面有一些元素。问题是,当我在浏览器中打开其中一个li元素时,其他li元素也会下降。这张照片供您理解
HTML:
<ul class="gadgets-list">
<li class="gadget"><img src="iconmonstr-keyboard-2-240.png" class="image">Keyboards<span class="caret"></span></a>
<p class="item">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</li>
<li class="gadget"><img class="image" src="iconmonstr-mouse-8-240.png">Mouses<span class="caret"></span></a></li>
<li class="gadget"><img class="image" src="iconmonstr-headphones-1-240.png">Headsets<span class="caret"></span></a></li>
<li class="gadget"><img class="image" src="iconmonstr-computer-1-240.png">Monitors<span class="caret"></span></a></li>
<li class="gadge"><img class="image" src="iconmonstr-cpu-1-240.png">Other components<span class="caret"></span></a></li>
CSS:
.gadgets-list {
background-color: white;
display: inline-block;
word-spacing: 50px;
width: 100%;
}
.item {
word-spacing: normal;
}
.gadge {
list-style: none;
word-spacing: normal;
display: inline-block;
}
p {
width: 450px
}
答案 0 :(得分:1)
您的css中存在拼写错误.gadget
而非.gadge
答案 1 :(得分:0)
将vertical-align: top;
添加到gadget
,因为li
是内嵌块元素,我猜这一切都正常。
请告诉我您的反馈意见。谢谢!
PS:小工具的拼写错误......:)
.gadgets-list {
background-color: white;
display: inline-block;
word-spacing: 50px;
width: 100%;
}
.item {
word-spacing: normal;
}
.gadget {
list-style: none;
word-spacing: normal;
display: inline-block;
vertical-align: top;
}
p {
width: 450px
}
&#13;
<ul class="gadgets-list">
<li class="gadget">
<img src="iconmonstr-keyboard-2-240.png" class="image">Keyboards<span class="caret"></span>
</a>
<p class="item">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</li>
<li class="gadget">
<img class="image" src="iconmonstr-mouse-8-240.png">Mouses<span class="caret"></span>
</a>
</li>
<li class="gadget">
<img class="image" src="iconmonstr-headphones-1-240.png">Headsets<span class="caret"></span>
</a>
</li>
<li class="gadget">
<img class="image" src="iconmonstr-computer-1-240.png">Monitors<span class="caret"></span>
</a>
</li>
<li class="gadget">
<img class="image" src="iconmonstr-cpu-1-240.png">Other components<span class="caret"></span>
</a>
</li>
&#13;