gpt4 book ai didi

bootstrap-4 - mx-auto不会将元素移动到中心

转载 作者:行者123 更新时间:2023-12-03 16:05:38 26 4
gpt4 key购买 nike

在下面的代码中,文本hello world没有使用mx-auto移动到屏幕的中心。问题是什么?

<div class="container-fluid">
<div class="row ">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 my-border" >
<div class="alert alert-success mx-auto" >
Hello World
</div>
</div>
</div>
</div>

最佳答案

mx-auto适用于具有固定宽度的div,请参见以下警报类:

.alert {
padding: $alert-padding-y $alert-padding-x;
margin-bottom: $alert-margin-bottom;
border: $alert-border-width solid transparent;
@include border-radius($alert-border-radius);
}

和mx-auto类:
.mx-auto {
margin-right: auto !important;
margin-left: auto !important;
}

改用 文本中心的

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<div class="container-fluid">
<div class="row ">
<div class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 my-border" >
<div class="alert alert-success text-center" >
Hello World
</div>
</div>
</div>
</div>

关于bootstrap-4 - mx-auto不会将元素移动到中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47427696/

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