我想用一個(gè)div容器來限定圖片的大小,怎么實(shí)現(xiàn)
我是這樣做的,但圖片總是不受div的控制
<style>
.box{
?? ?width:400px;
?? ?height:400px;
?? ?/*resize:both;
?? ?overflow:auto;*/
?? ?margin:0 auto;
?? ?background-color:#0C0;
?? ?
?? ?}
?? ?.box1{
?? ??? ?
?? ??? ?height:200px
?? ??? ?
?? ??? ?/*overflow:hidden;*/
?? ?
?? ??? ?}
?? ?.inner>img{
?? ??? ?/*position:absolute;*/
?? ??? ?padding:10px auto;
?? ??? ? margin:10%;
?? ??? ? }
?? ?
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標(biāo)題文檔</title>
</head>
<body>
<div class="box">
12344556
<img src="1.jpg"/>
</div>
</body>
</html>
2016-09-13
圖片層CSS
img{
? ?width:100%或者h(yuǎn)eight:100%;
}
是這種效果嗎?
2016-09-07
把圖片設(shè)成父級(jí)box的背景圖片。