[英]html, width 100% and padding
I have a problem with margins. 我的毛利率有问题。 I want to have image inside div element. 我想在div元素中有图像。 Height should be of the image, but width should be of the parent div minus padding. 高度应为图片的高度,宽度应为父div减去填充的宽度。
<div class="inner">
<img width="100%" src="http://pawelek-moj-aniolek.blog.onet.pl/wp-content/blogs.dir/505303/files/blog_bg_734362_1406866_tr_morze.jpg" alt="There is no image"/>
</div>
and styles 和样式
.inner {
width: 100%;
height: 100%;
margin: 10px;
position: relative;
}
.inner img {
width: 100%;
}
and the problem is easy to see on the image. 而且问题很容易在图像上看到。
http://i59.tinypic.com/zn6mc2.png I want to have 10 pixels of white place around each side of the image http://i59.tinypic.com/zn6mc2.png我想在图像的两边各留 10个像素的白色区域
I would use another div to wrap the image and give: 我将使用另一个div包装图像并给出:
padding:10px;
insteed of margin. 保证金。
here is a demo: http://jsfiddle.net/f6jju2mn/ 这是一个演示: http : //jsfiddle.net/f6jju2mn/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.