CSS:将图像定位在两行文本的左侧
就像标题所说,我不想创建一个可点击的列表,其中每个元素包含左侧的图像和右侧的两行文本。
现在我已经设法使用以下代码实现这些元素:
HTML:
<div class="verticalListItem">
<a href="#">
<div class="verticalItemImage"><img src="images/vdfLogo.png" width="80" height="80" /></div>
<div class="verticalItemText">
<p>Pop/Rock</p>
<p>0</p>
</div>
</a>
</div>
CSS:
.verticalListItem {
border: 1px solid #333;
}
.verticalItemImage {
float: left
}
.verticalItemImage img {
display: block;
}
我现在的结果是这样的:
但是,我的红色图像没有垂直居中,最糟糕的是:图像下方的区域和第二个标签,因此,第一个标签上方的区域(我在第二个元素上用绿色标记了这些区域)不可单击。我在这里做错了什么,你能帮我吗?
提前致谢!
Like the title says I wan't to create a clickable list, in which each element contains an image on the left and two lines of text on the right.
Right now I've manage to implement the elements with the following code:
HTML:
<div class="verticalListItem">
<a href="#">
<div class="verticalItemImage"><img src="images/vdfLogo.png" width="80" height="80" /></div>
<div class="verticalItemText">
<p>Pop/Rock</p>
<p>0</p>
</div>
</a>
</div>
CSS:
.verticalListItem {
border: 1px solid #333;
}
.verticalItemImage {
float: left
}
.verticalItemImage img {
display: block;
}
The result I have now is this:
However, my red image is not centered vertically and worst: the area bellow the image and the second label, so as the area above the first label (I've marked those areas with green on second element) is not clickable. What am I doing wrong here, can you help me please?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
未经测试不确定,但这应该对您有用。
Not sure without testing, but this should work for you.
这是解决方案 - http://jsfiddle.net/SaRnR/
here is the solution - http://jsfiddle.net/SaRnR/