gpt4 book ai didi

css - 如何为 div 上方的文本正确使用 Bootstrap 列?

转载 作者:行者123 更新时间:2023-11-28 03:56:41 24 4
gpt4 key购买 nike

这段代码真的让我很困惑。我在多个 div 上方有文字“Ways to Win”。问题是文本打乱了 div 的流动。但是,如果我从 Bootstrap 列中删除文本,它将不会响应并与其余的 div 一起流动。

如何使文本与其他 div 一起正确流动,同时又不干扰其下方的 div?

/* Ways to Win */

#win_text {
font-size: 20px;
position: relative;
font-weight: bold;
position: relative;
}

.win_box {
position: relative;
top: 50px;
height: 110px;
width: 196px;
border: 1px solid #C0C0C0;
border-bottom: none !important;
display: inline-block;
margin-bottom: 50px !important;
}

#video {
font-size: 45px;
color: white;
text-align: center;
vertical-align: middle;
position: relative;
top: 28px;
left: 80px;
text-shadow: 0px 0px 3px #353535;
}

.win_box:hover .description {
border: 1px solid #2A6496;
}

.win_box:hover {
border: 1px solid #2A6496;
}

.description {
position: relative;
top: 63px;
left: -1px;
padding: 5px;
border-top: none !important;
border: 1px solid #C0C0C0;
width: 196px !important;
}

.win_link {
text-decoration: nonew !important;
font-weight: bold !important;
text-decoration: none !important;
}

#win_row {
max-width: 1550px;
}

/* End of Ways to Win */
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Ways to Win -->

<br>

<div class='row' id='win_row'>

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>

<!-- Title -->
<span id='win_text'> Ways to Win </span> <br>

<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>

<!-- BREAK -->

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


</div>

<!-- Win Boxes -->

最佳答案

请确保您不对标题使用 span,它们必须是 block 元素。我还将您的标题放在自己的行中,以便与下面的内容分开。

另外,不要使用 break 标签来创建布局,它们不会清除您的行,而且会添加更难控制的额外空间。

您的布局现在可以使用了,您只需要整理标题和视频之间的间距即可:

/* Ways to Win */

#win_text {
font-size: 20px;
position: relative;
font-weight: bold;
position: relative;
}

.win_box {
position: relative;
top: 50px;
height: 110px;
width: 196px;
border: 1px solid #C0C0C0;
border-bottom: none !important;
display: inline-block;
margin-bottom: 50px !important;
}

#video {
font-size: 45px;
color: white;
text-align: center;
vertical-align: middle;
position: relative;
top: 28px;
left: 80px;
text-shadow: 0px 0px 3px #353535;
}

.win_box:hover .description {
border: 1px solid #2A6496;
}

.win_box:hover {
border: 1px solid #2A6496;
}

.description {
position: relative;
top: 63px;
left: -1px;
padding: 5px;
border-top: none !important;
border: 1px solid #C0C0C0;
width: 196px !important;
}

.win_link {
text-decoration: nonew !important;
font-weight: bold !important;
text-decoration: none !important;
}

#win_row {
max-width: 1550px;
}

/* End of Ways to Win */
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Ways to Win -->

<div class="container">
<div class="row">
<!-- Title -->
<div id='win_text'> Ways to Win </div>
</div>

<div class='row' id='win_row'>

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>


<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>

<!-- BREAK -->

<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


<div class="col-xs-5 col-sm-3 col-md-3 col-lg-2" id='title'>
<a href='#' class='win_link'> <div class='win_box' style='background: url("https://i.ytimg.com/vi/8sME-VxUQQA/hqdefault.jpg?custom=true&w=196&h=110&stc=true&jpg444=true&jpgq=90&sp=68&sigh=EgyGW3D0KWyu5ei-2aUz8FPI_Jc");'> <i class="fa fa-play" aria-hidden="true" id='video'></i>

<div class='description'> Earn 5 Points </div>

</div> </a>
</div>


</div>
</div>

<!-- Win Boxes -->

关于css - 如何为 div 上方的文本正确使用 Bootstrap 列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43423832/

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