【发布时间】:2022-01-23 04:35:44
【问题描述】:
我尝试使用填充、文本对齐中心、浮动和边距,但似乎没有任何效果,列表项都保持固定。和bootstrap的CSS或者JS有冲突吗?我对引导程序很陌生,对 CSS 和 HTML 也比较陌生,所以我可能遗漏了一些东西,但我似乎在这个问题上找不到其他任何东西。
这是我的代码(对于混乱的 cmets 感到抱歉):
/*controls the style of the entire navbar, including border and background clr*/
.navbar.navbar-default {
background-color: #D9D9D9;
border-color: #143DAF;
border-style: groove;
border-width: 5px;
text-align: center;
}
/*Controls the styles of the navbar brand, or the logo in the center*/
.navbar.navbar-default .navbar-brand {
color: #292929;
}
/*IDK, come back later but apears to have something to do with navbar brand hover*/
.navbar.navbar-default .navbar-brand:hover,
.navbar.navbar-default .navbar-brand:focus {
color: #ffffff;
background-color: #ffffff;
}
.navbar .navbar-center > ul {
padding-left: 30px;
padding-right: 30px;
text-align: center;
align-content: center;
float: right;
}
/*Again, IDK what this does, tho i think it is text, pottentially is being overwritten by the one below*/
.navbar.navbar-default .navbar-text {
color: #292929;
background-color: #000000;
}
/*will change the styles of all links within a list and a navbar, including the fb and ig logos*/
.navbar.navbar-default .navbar-nav > li > a {
color: #292929;
}
/*Link styling for when you hover over them*/
.navbar.navbar-default .navbar-nav > li > a:hover,
.navbar.navbar-default .navbar-nav > li > a:focus {
color: #6765eb;
}
/*Changes the color of the links when you hover over them when the active class is equiped*/
.navbar.navbar-default .navbar-nav > .active > a,
.navbar.navbar-default .navbar-nav > .active > a:hover,
.navbar.navbar-default .navbar-nav > .active > a:focus {
color: #6765eb;
background-color: #ffffff;
}
/*changes the color of the links when you hover over them with the active class*/
.navbar.navbar-default .navbar-nav > .open > a,
.navbar.navbar-default .navbar-nav > .open > a:hover,
.navbar.navbar-default .navbar-nav > .open > a:focus {
color: #ffd4d4;
background-color: #ffffff;
}
/*Hamburger Styling*/
.navbar.navbar-default .navbar-toggle {
border-color: #D9D9D9;
}
.navbar.navbar-default .navbar-toggle:hover,
.navbar.navbar-default .navbar-toggle:focus {
background-color: #D9D9D9;
}
.navbar.navbar-default .navbar-toggle .icon-bar {
background-color: #292929;
}
.navbar.navbar-default .navbar-link {
color: #292929;
}
/*HAMBURGER OVER*/
/*changes the color of the links when you hover over them*/
.navbar.navbar-default .navbar-link:hover {
color: #ffd4d4;
}
/*Adjusts the position and aditional styles of the navbar brand (logo)*/
.navbar-brand {
transform: translateX(-50%);
left: 7%;
position: absolute;
padding: 0px;
}
/*Changes the style of the navbar, including the fonts*/
.nav.navbar-nav > li.navbar-center {
font-family: 'Nunito Sans', sans-serif;
font-size: 11px;
}
.navbar-brand > img {
height: 90%;
width: auto;
}
/*Adjust padding and position of the nav*/
@media (min-width:768px) and (max-width:991px){
.container.navbar-container {
width:100%;
padding:0;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title> My Website</title>
<!--Gives access to ig fb pintrest & twitter--><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="style.css" />
<link href="https://fonts.googleapis.com/css?family=Nunito|Nunito+Sans|Playfair+Display" rel="stylesheet">
<!---Bootstrap CSS & JS---->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
<header>
<div class="container navbar-container">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<!---"Hamburger" drop-down menu--->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-----Logo (right now its the settings wheel)----->
<a class="navbar-brand" href="http://jh.com"><img class= "logo" src="https://cdn2.iconfinder.com/data/icons/social-productivity-line-art-2/128/settings-gear2-512.png"></a>
</div>
<!---The ul and links of the navbar--->
<div id="navbar" class="navbar-collapse collapse">
<!--The html links, navbar-left specifies that they will be on the left side of the bar, and is also used for txt styling-->
<ul class="nav navbar-nav">
<li class="navbar-center"><a href="index.html">HOME</a></li>
<li class="navbar-center"><a href="#"> INFORMATION</a></li>
<li class="navbar-center"><a href="#"> HISTORY </a></li>
<li class="navbar-center"><a href="#"> ATTRACTIONS </a></li>
<li class="navbar-center"><a href="#"> GALLERIES </a></li>
<li class="navbar-center"><a href="#"> CONTACT US </a></li>
</ul>
<!--similar to above, except this is used for ig fb and twitter logos+links, navbar-right is in the opening <div> since it isn't needed for txt styling anymore-->
<ul class="nav navbar-nav navbar-right">
<li> <a href="https://www.instagram.com"><i class="fa fa-instagram"></i></a>
<li> <a href="https://www.pinterest.com"><i class="fa fa-pinterest"></i></a>
<li> <a href="https://www.facebook.com"><i class="fa fa-facebook"></i></a>
<li> <a href="https://twitter.com"><i class="fa fa-twitter"></i></a>
</ul>
</div>
<!--/.nav-collapse -->
</div>
<!--/.container-fluid -->
</nav>
</div>
</header>
</body>
</html>
【问题讨论】:
标签: html css bootstrap-4 navbar