嗨,我真的被困住了。我会一步一步来,希望能把它缩短。
这是html结构:
<li class="FAVwithimage">
<a href="">
<img src="pics/Joshua.png">
<span class="name">Joshua</span>
<span class="comment">Developer</span>
<span class="arrow"></span>
</a>
</li>
在我粘贴 css 类之前,一些关于要完成的确切目标的信息:
将图片 (img) 的大小调整 57%。如果不能用 css 完成,那么 jquery/javascript 解决方案。例如:原始图片为 240x240 像素,我需要将其大小调整 57%。这意味着调整大小后 400x400 的图片会更大。
调整大小后,图片需要在 a: 68x90 边界内垂直和水平居中。所以你有一个 LI 元素,它有一个 A 元素,在 A 里面我们有 IMG,IMG 被调整了 57% 并居中,最大宽度可以
当然是 68px 和最大高度 90px。不,我在 IMG 周围添加了一个 SPAN 元素。
这就是我的想法:
<li class="FAVwithimage">
<a href="">
<span class="picHolder"><img src="pics/Joshua.png"></span>
<span class="name">Joshua</span>
<span class="comment">Developer</span>
<span class="arrow"></span>
</a>
</li>
然后我会给出 span 元素:display:block 和 w=68px,h=90px。但不幸的是,这并没有奏效。
我知道这是一篇很长的帖子,但我已尽力将其描述得非常简单。下面是css类和一张图片,看看我需要什么。
li.FAVwithimage {
height: 90px!important;
}
li.FAVwithimage a, li.FAVwithimage:hover a {
height: 81px!important;
}
这就是相关的。我没有包括以下类:名称、评论、箭头
现在是不完整的类,请参考 IMG。
li.FAVwithimage a span.picHolder{
/*put the picHolder to the beginning
of the LI element*/
position: absolute;
left: 0;
top: 0;
width: 68px;
height: 90px;
diplay:block;
border:1px solid #F00;
}
边框只是临时用来显示实际的 picHolder。现在在 LI 的开头,设置了宽度和高度。
li.FAVwithimage span.picHolder img
{
最大宽度:68px!重要;最大高度:90px!重要;这是应该将图片缩小 57% 并在 picHolder 中居中的类
在这里,我有一张描述我需要的图: