gpt4 book ai didi

jquery - 如何对齐 div 的 Bootstrap 列中间?

转载 作者:行者123 更新时间:2023-11-28 15:20:01 27 4
gpt4 key购买 nike

this is my demo page我的 div 中有 Bootstrap 列,父类是绝对的,但我的列不在旋转木马的中间。该怎么做?

然后我将图像添加到我想做的事情中 enter image description here

你可以看到我的结构

html

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap 101 Template</title>

<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>

<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">

<div class="myDiv ">
<div class="container">
<div class="row">
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">left column..</div>
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">right column..</div>
</div>
</div>
</div>
<div class="item active">
<img src="http://www.aurumhotels.com.tr/resimler/normal/2015-08/FirmaArkaBanner1_4BuFjQUcCp3yALBpDUxLsignature.jpg" alt="...">
</div>
<div class="item">
<img src="http://www.aurumhotels.com.tr/resimler/normal/2015-12/FirmaArkaBanner1_Isrgao2xv47jrJVBsf2Hfirmaarkabanner2.png" alt="...">
</div>
</div>

<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>

CSS

.my-slider{
background:#FFF;
position: absolute;;
top:0;
z-index:1;
}
.item img {
width:100%;
}

最佳答案

你可以这样做:

.myDiv{
position: absolute;
background: #fff;
z-index:1;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
width: 50%;

http://codepen.io/anon/pen/zqWmYB

关于jquery - 如何对齐 div 的 Bootstrap 列中间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36629333/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com