我正在尝试使图像响应浏览器的大小,以便当浏览器较小时,图像会响应,从而不涉及滚动。我在这里发现了一个类似的问题How can I resize an image dynamic with CSS as the browser width/height changes?,但我无法使该解决方案发挥作用。我错过了什么?
我在下面包含我的代码 - 我使用的是 Wordpress,所以它会自动在我的图像周围放置一个“p”标签,将我的图像包装在一个段落中。另外,我不确定我是否为此目的包含了太多代码,但我想确保它都在那里,以防万一在一个可能导致问题的奇怪地方出现错误......
这是我的html:
<body>
<div id="pop_up_page">
<div class="content_well_pop">
<div class="content_pop">
<div class="portfolio_workspace_9">
<h2>Here's the Header</h2>
</div>
<div class="portfolio_workspace_8">
<p>
<img src="heres_the_image"/>
</p>
</div>
</div>
</div>
</div>
</body>
这是我的CSS:
body {
background-attachment: fixed;
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
padding: 0;
height: 100%;
}
#pop_up_page {
background-attachment: fixed;
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
padding: 0;
height: 100%;
.content_well_pop {
left: 0;
width: 100%;
}
.portfolio_workspace_9 {
width: 1000px;
margin: 15px 0 0 0px;
position: relative;
float: left;
display:block;}
.portfolio_workspace_8 {
width: 1000px;
margin: 0px 0 50px 0px;
position: relative;
float: left;
height: auto;
display:block;}
p{font-family: "Franklin Gothic Book";
font-size: 15px;
color: #757372;
display: block;
}
.portfolio_workspace_8 img {
margin-left: auto;
margin-right: auto;
display: block;
max-width: 100%;
height: auto;
}
谢谢