[英]Inner div not positioning to bottom right
I have a Bootstrap grid column nested with two divs: The parent div is an image and the child div is an opaque color. 我有一个嵌套有两个div的Bootstrap网格列:父div是图像,子div是不透明的颜色。 I am attempting to align the child div to the bottom right of the parent div.
我正在尝试将子div对准父div的右下角。 However, when I apply absolute positioning for this alignment, the whole div inappropriately moves upward.
但是,当我对这种对齐方式应用绝对定位时,整个div都会不适当地向上移动。 Any suggestions of how to prevent this upward movement yet align the child div (
oqaque-7
) to the bottom right of the parent div ( col-md-4
). 关于如何防止这种向上移动的任何建议,
oqaque-7
使子div( oqaque-7
)与父div( col-md-4
)的右下对齐。
The HTML: HTML:
<div class="row-eq-height">
<div class="col-md-4" id="col-7">
<div class="opaque-7">
<h4>ABC</h4>
<h3>ddddddddddd eeeeee</h3>
<h3>PPPPP</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque venenatis euismod nvallis vel. Fusce Vitae Quisque venenatis euismod</p>
<button type="button" class="btn btn-secondary" id="btn-7" onclick="location.href='/#/'">
DISCOVER
</button>
</div><!--.opaque-7-->
</div><!--.col-md-4-->
</div><!--.row-eq-height-->
The CSS: CSS:
.row-eq-height{
display: flex;
flex-wrap: wrap;
}
#col-7{
background-image:url('/site/templates/images/image.jpg');
border: none;
}
.opaque-7{
background-color:#24B5B0;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
-khtml-opacity: 0.8;
opacity: 0.8;
padding-left:5%;
padding-top:10%;
padding-bottom:10%;
bottom:0;
margin-top:40%;
position: absolute;
float:right;
}
#col-7 h4{
color: white;
text-align: left;
}
#col-7 h3{
color:white;
text-align:left;
margin-top:-10px;
}
#col-7 p{
color:white;
text-align: left;
}
#btn-7{
background-color:#30CFCA;
color:white;
float:left;
margin-top: 10%;
margin-bottom: -6%;
display: block;
}
You might want to give the width of the child as 90% , remove float and margin-top on the child. 您可能希望将子项的宽度设置为90% ,删除子项上的float和margin-top。 See this: https://jsfiddle.net/GunWanderer/asugvrw9/
看到这个: https : //jsfiddle.net/GunWanderer/asugvrw9/
.opaque-7{
background-color:#24B5B0;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80);
-khtml-opacity: 0.8;
opacity: 0.8;
padding-left:5%;
padding-top:10%;
padding-bottom:10%;
bottom:0;
position: absolute;
right: 0;
width: 90%;
}
You'll need the child element to position itself relative to the parent div instead of the body of the html page. 您将需要child元素相对于父div(而不是html页面的主体)相对于自身定位。 Add
position:relative;
添加
position:relative;
to the CSS of the parent element. 到父元素的CSS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.