Javascript 垂直和水平定心div
有没有办法使.polygon_容器和.polygon垂直和水平居中?还有没有可能使它的大小像下面的标签一样灵敏 我试过文本对齐、边距自动调整等,但都没有效果Javascript 垂直和水平定心div,javascript,jquery,html,css,Javascript,Jquery,Html,Css,有没有办法使.polygon_容器和.polygon垂直和水平居中?还有没有可能使它的大小像下面的标签一样灵敏 我试过文本对齐、边距自动调整等,但都没有效果 当我用左边和边距设置中间时,它只适用于一个分辨率。 你可以很容易地使用FrasBox。 .owl-item > div { display: flex; justify-content: center; align-items: center; } 可以使用tansform将多边形div居中: 我创建了以下H
当我用左边和边距设置中间时,它只适用于一个分辨率。
你可以很容易地使用FrasBox。
.owl-item > div {
display: flex;
justify-content: center;
align-items: center;
}
可以使用tansform将多边形div居中: 我创建了以下HTML:
<div class="polygon_container">
<div class="polygon">
<h1>hello</h1>
</div>
</div>
希望这是您的解决方案。是的,这是可能的。试试这个
.polygon_container {
position: absolute;
height: 500px;
width: 500px;
top: 50%;left: 50;
margin-left: -250px;
margin-top: -250px;
}
html,正文{
高度:100%;宽度:100%;
边距:0;填充:0;
}
.集装箱{
高度:100%;宽度:100%;
背景:url'http://cichyone.linuxpl.eu/ranestwen/ex/assets/img/slider1/1.png"不重复,;
背景尺寸:封面;
}
.集装箱{
位置:绝对位置;
高度:100px;
宽度:100px;
左侧:50%;顶部:50%;
利润上限:-50px;
左边距:-50px;
}
.polygon_容器.polygon{
背景:fff;
身高:100%;
宽度:100%;
变换:旋转45度;
}
更新您的类。只需使用以下css
.slider .polygon_container {
position: absolute;
left:0px;
right:0px;
top:0px;
bottom:0px;
margin: auto;
color: white;
height: 500px;
text-align: center;
width: 500px;
z-index: 99999;
}
.slider .polygon {
color: white;
height: 500px;
margin: auto;
position: absolute;
left:0px;
right:0px;
top:0px;
bottom:0px;
width: 500px;
z-index: 99999;
}
添加代码片段,而不是发布网站url。
.slider .polygon_container {
width: 500px;
height: 500px;
position: absolute;
z-index: 99999;
text-align: center;
color: white;
margin: 0 auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.slider .polygon_container {
position: absolute;
left:0px;
right:0px;
top:0px;
bottom:0px;
margin: auto;
color: white;
height: 500px;
text-align: center;
width: 500px;
z-index: 99999;
}
.slider .polygon {
color: white;
height: 500px;
margin: auto;
position: absolute;
left:0px;
right:0px;
top:0px;
bottom:0px;
width: 500px;
z-index: 99999;
}