我几乎不敢问这个问题,因为它看起来很明显,但是我找不到一个明确的答案,因此冒着损害我不存在的声誉的风险,这里是:
有没有一种方法可以在悬停时向图像添加扩展的CSS内部边界,而又不影响图像的大小?
这是我自己获得的代码:
的CSS
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
.media_item_container img {
border: 3px solid #00205f;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
}
.media_item_container img:hover {
border: 10px solid #00205f;
}
.media_item_container a
{
font-weight:bold;
color:#000;
text-decoration:none;
font-size:13px;
}
.media_item_container a:hover
{
color:#fff;
}
的HTML
<body bgcolor="#999999">
<div class="media_item_container">
<div class="media_item_text">
<a href="#"><img src="http://lorempixel.com/output/business-q-c-158-158-5.jpg" width="158" height="158" class="media_item_thumb" />
<h3>E-Brochure: <em>Printable e-brochure</em></h3>
DOWNLOAD »</a>
</div>
</div>
</body>
只是尝试确定是否有任何方法可以在不随着边框大小增加而缩小图像的情况下进行缩放(我基本上理解了为什么会这样,只是我自己似乎无法提出解决方案)。
当我问是否有办法做到这一点时,我应该澄清一下,我认为一定有某种办法可以做到这一点,但是我很想知道是否有一个相对简单的办法。
非常感谢!
配合,这是我想出的解决方案。必须更改一些HTML和CSS,但这是我的工作。希望这可以帮助伴侣,干杯
HTML:
<body bgcolor="#999999">
<div class="media_item_container">
<div class="media_item_text">
<a href="#">
<div class="border" style="background: url(http://lorempixel.com/output/business-q-c-158-158-5.jpg);">
</div>
<h3>E-Brochure: <em>Printable e-brochure</em></h3>
DOWNLOAD »</a>
</div>
</div>
CSS:
.border {
-webkit-transition: all 500ms linear;
-o-transition: all 500ms linear;
-moz-transition: all 500ms linear;
-ms-transition: all 500ms linear;
-kthtml-transition: all 500ms linear;
transition: all 500ms linear;
width: 158px;
height: 158px;
}
.border:hover {
-webkit-box-shadow: inset 0px 0px 2px 10px #00205f;
box-shadow: inset 0px 0px 2px 10px #00205f;
}
.media_item_container a
{
font-weight:bold;
color:#000;
text-decoration:none;
font-size:13px;
}
.media_item_container a:hover
{
color:#fff;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句