右图已被已应用overflow:hidden的父div截断。也许这是不可能的,但如果这样,如何使图像不被切断?
https://jsfiddle.net/kimwild/q3vwthky/2/
figure#main-img,
figure#main-img-black {
width: 100%;
overflow: hidden;
}
figure#main-img-black {
background-color: #000000;
}
section#title {
margin: 10px auto;
padding: 0 .83333%;
/* 10px / 1200px */
max-width: 1200px;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
}
section#title #hgroup {
float: left;
width: 100%;
z-index: 9020;
position: relative;
}
.parent {} figure#main-img img,
figure#main-img-black img {
/* max-width: 1400px;*/
max-width: 500px;
width: 100%;
right: 0;
top: 0;
position: absolute;
z-index: -1;
}
section#title h1.white,
section#title h1.black {
font-size: 4em;
line-height: 1em;
width: 60%;
padding: 0;
}
section#title h1.white {
color: #FFFFFF;
}
section#title h2.white,
section#title h2.black {
color: #FFFFFF;
font-size: 2em;
line-height: 1.2em;
font-weight: normal;
margin-top: 10px;
width: 40%;
}
section#title h2.white {
color: #FFFFFF;
}
<figure id="main-img-black">
<section id="title">
<div id="hgroup">
<div class="parent">
<img src="http://hauppauge.com/responsive/pics/hdpvr-rocket_top5.jpg" alt="" />
</div>
<h1 class="white">HD PVR
Rocket </h1>
<h2 class="white">Portable Game Recorder</h2>
</div>
</section>
</figure>
最佳答案
一种方法是将float: right;
放在.parent
上,如下所示:
.parent { float :right; }
另外,删除img上的绝对位置。
See this fiddle
关于html - 内容被父div切断,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36185689/