[英]css transform scale doesn't scale parent element
I have 2 image with a link, i'm tring to scale them down to 50% of original image size, each image has a different size我有 2 个带有链接的图像,我正在尝试将它们缩小到原始图像大小的 50%,每个图像都有不同的大小
if i add a back border i can see that image is correctly scaled down to half size but A tog is in original size如果我添加一个后边框,我可以看到图像正确缩小到一半大小,但 A tog 是原始大小
I'm also using bootstrap 3 in this page我也在这个页面中使用 bootstrap 3
<div class="header-tit-logos">
<a href="http://www.mylink.com" target="_blank"><img src="static/images/img1.png" alt="img 1" width="60" height="117"></a>
<a href="http://www.mylink.com" target="_blank"><img src="static/images/img2.png" alt="img 2" width="145" height="54"></a>
</div>
.header-tit-logos a {
display: inline-block;
}
.header-tit-logos img {
-ms-transform: scale(0.5);
-webkit-transform: scale(0.5);
transform: scale(0.5);
}
You cannot apply style to a parent from a child. 您不能将样式应用于孩子的父母。 In your case you can try to scale the parent. 您可以尝试缩放父级。 It'll scale both the parent and the children 它将缩放父母和孩子
.header-tit-logos {
-ms-transform: scale(0.5);
-webkit-transform: scale(0.5);
transform: scale(0.5);
}
Try removing width and height from img tag. 尝试从img标签中删除宽度和高度。
.header-tit-logos a { background:red; display: inline-block; } .header-tit-logos img { -ms-transform: scale(0.5); -webkit-transform: scale(0.5); transform: scale(0.5); }
<div class="header-tit-logos"> <a href="http://www.mylink.com" target="_blank"><img src="http://media.istockphoto.com/photos/medium-golden-brown-wood-texture-background-picture-id513694258?k=6&m=513694258&s=170667a&w=0&h=xETakP7VjpAtRj9e6rJRYNqw_AJLZ9ovLlC4ebR5BOQ=" alt="img 1" width="60" height="117"></a> <a href="http://www.mylink.com" target="_blank"><img src="https://image.freepik.com/free-vector/abstract-background-in-geometric-style_1013-17.jpg" alt="img 2"></a> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.