gpt4 book ai didi

html - 添加Bootstrap CDN后部分html元素下移

转载 作者:太空宇宙 更新时间:2023-11-04 09:43:50 24 4
gpt4 key购买 nike

在我添加 Bootstrap CDN 之后,我所有的一些 html 元素都向下移动了。例如导航栏,页脚中的 p。这恰好在向标题添加链接之后发生。如果我将其注释掉,问题就会消失。

有人知道怎么解决吗?

* {
margin: 0;
padding: 0;
}

body {
min-width: 800px;
}

header {
width: 100%;
position: fixed;
height: 40px;
line-height: 40px;
overflow: hidden;
min-width: inherit;
z-index: 1;
}

.base {
background: #333333;
}

nav {
position: relative;
}

.logo {
float: left;
height: 100%;
padding: 0 20px;
}

.logo:hover {
background: #404040;
}

#logo_img {
height: 30px;
vertical-align: middle;
}

ul {
list-style-type: none;
}

a {
text-decoration: none;
}

nav li {
float: left;
width: 100px;
text-align: center;
color: #f2f2f2;
font-family: "Calibri";
font-size: 20px;
}

nav li:hover {
background: #404040;
}

#social {
float: right;
margin-right: 7px;
line-height: 35px;
}

#social li {
float: left;
text-align: center;
color: #f2f2f2;
padding: 0 4px;
}

#social li:hover {
background: #404040;
}

#social img {
height: 35px;
vertical-align: middle;
}

footer {
color: white;
height: 25px;
width: 100%;
padding: 5px;
position: fixed;
bottom: 0;
right: 0;
cursor: default;
border: none;
overflow: hidden;
min-width: inherit;
z-index: 1;
}

footer a {
color: #007acc;
}

footer a:hover {
color: #007acc;
text-decoration: underline;
}

footer p {
color: #e6e6e6;
margin: 5px 15px;
font-size: 12px;
font-family: "Lucida Sans Unicode";
}

#info {
float: left;
}

#footer_name {
float: right;
}
<!DOCTYPE html>
<html>
<head>
<title>Home</title>

<link type="text/css" href="css/main.css" rel="stylesheet">

<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">

<!--Bootstrap links-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

</head>
<body>

<header class="base">

<div class="logo">
<a href="#"><img id="logo_img" src="img/logo.png"></a>
</div>

<nav>
<ul>
<a href="#"><li><span class="menu_item">Home</span></li></a>
<a href="#"><li><span class="menu_item">Diary</span></li></a>
<a href="#"><li><span class="menu_item">Foods</span></li></a>
<a href="#"><li><span class="menu_item">Settings</span></li></a>
<a href="#"><li><span class="menu_item">About</span></li></a>
</ul>
</nav>

<div id="social">
<ul>
<a href="#"><li><img class="social_icons" src="img/facebookc.png"></li></a>
<a href="#"><li><img class="social_icons" src="img/twitterc.png"></li></a>
<a href="#"><li><img class="social_icons" src="img/instagramc.png"></li></a>
</ul>
</div>
</header>

<footer class="base">
<p id="info">This website was created by a student of Wroclaw University of Technology.&emsp;<a href="#">Contacts</a></p>
<p id="footer_name">Copyright &copy; 2016 FitIt, Inc.</p>
</footer>


<!--Scripts-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

</body>
</html>

Bottom pic navbar and social icons and text in footer are shifted...

最佳答案

是的,当使用像 <nav> 这样的常见标签时,这总是一个问题, <header> , <footer>等等。因为这些元素是使用 Bootstrap 设置样式的,并且与现有样式发生冲突。

你有几种方法:

1) 使当前/现有样式声明更加严格,即

nav ul li { property:value!important;}

2) 像这样更改标记名:

然后

nav.mynav ul li {property:value;}

3) 更改 nav等标签分类 div ,所以你将有:

 <div class="my_navig">
<ul>
<a href="#"><li><span class="menu_item">Home</span></li></a>
<a href="#"><li><span class="menu_item">Diary</span></li></a>
<a href="#"><li><span class="menu_item">Foods</span></li></a>
<a href="#"><li><span class="menu_item">Settings</span></li></a>
<a href="#"><li><span class="menu_item">About</span></li></a>
</ul>
</div>

关于html - 添加Bootstrap CDN后部分html元素下移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39669565/

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