gpt4 book ai didi

html - 内联 block 不工作 Bootstrap

转载 作者:太空宇宙 更新时间:2023-11-04 07:35:56 25 4
gpt4 key购买 nike

出于某种原因,我无法使第 2 列中的元素与内联 block 元素对齐,无论是使用 Bootstrap HTML d-inline-block 还是应用了我自己的 CSS 内联 block 。我名为 MainPage.css 的样式表是否优先于 bootstrap 似乎并不重要。

HTML

<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="MainPage.css">
<title>Hello, world!</title>
</head>
<body>
<!-- <h1>Hello, world!</h1> -->
<div class="container-fluid">
<div class="row vh">
<div class="col-md-2 pt-3">

<ul id="socialmedia">
<li><a class="pl-2" id="facebook" href="https://www.facebook.com/"><img src="facebook16.png"/></a></li>
<li><a class="pl-2" id="twitter" href="https://www.twitter.com/"><img src="twitter16.png"/></a></li>
<li><a class="pl-2" id="instagram" href="https://www.twitter.com/"><img src="instagram16.png"/></a></li>
<li><a class="pl-2" id="youtube" href="https://www.twitter.com/"><img src="youtube16.png"/></a></li>
<li><a class="pl-2" id="spotify" href="https://www.twitter.com/"><img src="spotify16.png"/></a></li>
</ul>
</div>


<div class="col-md-6 pt-4">

<ul id="leftbanner">
<li><a class="" id="News" href="https://www.google.com/">News</a></li>
<li><a class="pl-2" id="Photos" href="https://www.google.com/">Photos</a></li>
<li><a class="pl-2" id="Tour" href="https://www.google.com/">Tour</a></li>
<li><a class="pl-2" id="Games" href="https://www.google.com/">Games</a></li>
</ul>

<p id="centerpage">BlackBird | Blue Bird</p>


<ul id="rightbanner">
<li><a class="" id="News" href="https://www.google.com/">News</a></li>
<li><a class=" pl-2" id="Photos" href="https://www.google.com/">Photos</a></li>
<li><a class=" pl-2" id="Tour" href="https://www.google.com/">Tour</a></li>
<li><a class=" pl-2" id="Games" href="https://www.google.com/">Games</a></li>
</ul>


</div>

<div class="col-md-4">
</div>

</div>
</div>

<!-- Optional JavaScript color #4f4f52 -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
</body>
</html>

CSS

body {
background-attachment: fixed;
background-image: url(BG1.jpg);
background-position: center;
background-repeat: no-repeat;
/* background-size: 100% 100%; */
background-size: cover;
margin: 0%;
padding: 0%;
}


#socialmedia li {

list-style-type: none;
display: inline;

}

#leftbanner li {

list-style-type: none;
display: inline-block;

}


#rightbanner li {

list-style-type: none;
display: inline-block;

}

#centerpage{

display: inline-block;

}
.container-fluid{

padding:0;
margin:0;
}

.vh div{
height: 7vh;
background: #f9f9fa;

}

最佳答案

如果将 d-inline-block 类添加到 li 项,它会按预期工作。 (见下面的代码片段)。

但是,您可能更愿意使用 Bootstrap 4 nav 类来完成这项工作,因为它们正是为此而设计的,并且比使用 d-inline-block 更容易 本例中的类。

引用:https://getbootstrap.com/docs/4.0/components/navs/

这是一个有效的代码片段:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<div class="container-fluid">
<div class="row vh">
<div class="col-md-2 pt-3">

<ul id ="socialmedia" class="list-unstyled">
<li><a class="pl-2" id ="facebook" href="https://www.facebook.com/"><img src="https://placehold.it/24"/></a></li>
<li><a class="pl-2" id ="twitter" href="https://www.twitter.com/"><img src="https://placehold.it/24"/></a></li>
<li><a class="pl-2" id ="instagram" href="https://www.twitter.com/"><img src="https://placehold.it/24"/></a></li>
<li><a class="pl-2" id ="youtube" href="https://www.twitter.com/"><img src="https://placehold.it/24"/></a></li>
<li><a class="pl-2" id ="spotify" href="https://www.twitter.com/"><img src="https://placehold.it/24"/></a></li>
</ul>
</div>

<div class="col-md-6 pt-4">

<ul id ="leftbanner" class="list-unstyled">
<li class="d-inline-block"><a class="" id ="News" href="https://www.google.com/">News</a></li>
<li class="d-inline-block"><a class="pl-2" id ="Photos" href="https://www.google.com/">Photos</a></li>
<li class="d-inline-block"><a class="pl-2" id ="Tour" href="https://www.google.com/">Tour</a></li>
<li class="d-inline-block"><a class="pl-2" id ="Games" href="https://www.google.com/">Games</a></li>
</ul>

<p id ="centerpage">BlackBird | Blue Bird</p>

<ul id ="rightbanner" class="list-unstyled">
<li class="d-inline-block"><a class="" id ="News" href="https://www.google.com/">News</a></li>
<li class="d-inline-block"><a class=" pl-2" id ="Photos" href="https://www.google.com/">Photos</a></li>
<li class="d-inline-block"><a class=" pl-2" id ="Tour" href="https://www.google.com/">Tour</a></li>
<li class="d-inline-block"><a class=" pl-2" id ="Games" href="https://www.google.com/">Games</a></li>
</ul>
</div>

<div class="col-md-4">
</div>
</div>
</div>

关于html - 内联 block 不工作 Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48957565/

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