2016-09-15 59 views
-6

具有如下:内的DIV图片CSS

<div class="big-container"> 
    <div class="header">many things here that must be fixed on top of the page</div> 

    <div class="content"> 
     <img src="image"/> <!--Must expand the content div to the size of the image --> 
     <div class="footer"> Must be inside the image but at the bottom</div> 
    </div> 
</div> 

<!-- .content and .header must be at the same top, .content is much higher than header--> 

我与相对和绝对,但页面响应想,我不能设置。内容

的高度什么是CSS ?

+0

很多东西 “这里” - 在哪里?请提供比此更多的信息。可能是一个[Fiddle](http://jsfiddle.net) –

+1

寻求代码帮助的问题必须包含在问题本身中重现**所需的最短代码**,最好在[** Stack Snippet **](https: //blog.stackoverflow.com/2014/09/introducing-runnable-javascript-css-and-html-code-snippets/)。请参阅[**如何创建最小,完整和可验证的示例**](http://stackoverflow.com/help/mcve) –

回答

0

即使没有尝试,也不能直接询问代码。检查下面的代码。这可能会有所帮助。

.header{ 
 
background:red; 
 
    width:100%; 
 
    position:fixed; 
 
    top:0; 
 
} 
 

 
.content{ 
 
margin-top: 30px; 
 
position: relative; 
 
min-width: 300px; 
 
max-width: 500px; 
 
} 
 
.content img{ 
 
position: relative; 
 
height: 300px; 
 
width: 100%; 
 
} 
 
.content .footer{ 
 
background: gray; 
 
position: absolute; 
 
width: 100%; 
 
bottom: 0px; 
 
}
<div class="big-container"> 
 
    <div class="header">many things here that must be fixed on top of the page</div> 
 

 
    <div class="content"> 
 
     <img src="http://r.ddmcdn.com/s_f/o_1/cx_633/cy_0/cw_1725/ch_1725/w_720/APL/uploads/2014/11/too-cute-doggone-it-video-playlist.jpg"/> <!--Must expand the content div to the size of the image --> 
 
     <div class="footer"> Must be inside the image but at the bottom</div> 
 
    </div> 
 
</div>