gpt4 book ai didi

html - 在导航栏中向菜单添加文本会关闭按钮。

转载 作者:行者123 更新时间:2023-11-28 10:25:36 24 4
gpt4 key购买 nike

这是我第一次发布问题,希望我没有违反任何命令 - 这是我的问题:

我为我的站点制作了一个导航栏,如下所示。但是,每当我添加文本(请参阅:主页)时,它都会将菜单按钮推离导航栏。我试过修改边距和填充,但无济于事。如果需要,我会在下面的网站上提供完整的 HTML。

谢谢大家!

编辑:我做了一个 jsfiddle 来更好地说明我的观点。

http://jsfiddle.net/6JK3E/

<div id="nav">

<div class="menubutton">

<div class="menustyle">

<a href="#">

Home

</a>

</div>

</a>

</div>

<div class="menubutton">

</div>

<div class="menubutton">

</div>

<div class="menubutton">

</div>

<div class="menubutton">

</div>

<div class="lastmenubutton">

</div>

相关 CSS:

    #wrapper
{
width:950;
height:100%;
margin:0px auto 0px auto;
-webkit-box-shadow: 0px 0px 16px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 0px 0px 16px 0px rgba(50, 50, 50, 0.75);
box-shadow: 0px 0px 16px 0px rgba(50, 50, 50, 0.75);
min-height: 1045px;
background-color: white;
}

#header
{
width: 950px;
margin: 0px auto 0px auto;
height: 200px;
}

#logo
{
width: 950px;
margin: 0px auto 0px auto;
height: 140px;
background-image: url("../img/logo.png");
background-repeat: no-repeat;
}

#bluebar1
{
width: 950px;
margin: 0px auto 0px auto;
height: 10px;
border-bottom: 1px solid rgba(86, 177, 255, 1);
background-color: rgba(103, 185, 255, 0.43);
}

#bluebar2
{
width: 950px;
margin: 0px auto 0px auto;
height: 10px;
border-top: 1px solid rgba(86, 177, 255, 1);
background-color: rgba(103, 185, 255, 0.43);
margin-top: -1px;
}

#bluebar3
{
width: 950px;
margin: 0px auto 0px auto;
height: 10px;
border-top: 1px solid rgba(86, 177, 255, 1);
background-color: rgba(103, 185, 255, 0.43);
margin-top: 1px;
}

#nav
{
width: 950px;
margin: 0px auto 0px auto;
height: 50px;
border-top: 1px solid rgba(177, 177, 177, 0.47);
}

.menubutton
{
width: 144px;
height: 48px;
background-color: white;
display: inline-block;
text-align: center;
padding-left: 5px;
padding-right: 5px;
border-right: 1px solid rgba(177, 177, 177, 0.47);
}

.lastmenubutton
{
width: 144px;
height: 48px;
background-color: white;
display: inline-block;
text-align: center;
padding-left: 5px;
padding-right: 5px;
}

/*** Menu Buttons ***/

.menustyle
{
font-family: 'Bree Serif', serif;
font-size: 18px;
color: rgb(0, 54, 80);
}

/*** ***/

完整站点 HTML 和 CSS:

    <html>

<title>BlueCloudGaming</title>

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

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="description" content="">

<meta name="author" content="">

<link rel="shortcut icon" href="../img/favicon.ico">

<!-- Google Fonts -->

<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700|Lora|Open+Sans|Bree+Serif' rel='stylesheet' type='text/css'>

<head>

</head>

<body>

<div id="wrapper">

<div id="header">

<div id="bluebar1">

</div>

<div id ="logo">

</div>

<div id="nav">

<div class="menubutton">

<div class="menustyle">

<a href="#">

Home

</a>

</div>

</a>

</div>

<div class="menubutton">

<a href="#">

Home

</a>

</div>

<div class="menubutton">

</div>

<div class="menubutton">

</div>

<div class="menubutton">

</div>

<div class="lastmenubutton">

</div>

</div>

<div id="bluebar2">

</div>

</div>

<div id="content">

<div id="servertitlewrap">

<div class="servertitle">

<a href="#"><div class="servertitlefont">

Trouble in Terrorist Town

</div>

<div class="serverp">

Click to connect!

</div></a>

</div>

<div class="servertitlediv">

</div>

<div class="servertitle">

<a href="#"><div class="servertitlefont">

DarkRP v.3.1.6b

</div>

<div class="serverp">

Click to connect!

</div></a>

</div>

<div class="servertitlediv">

</div>

<div class="servertitle">

<a href="#"><div class="servertitlefont">

Starbound

</div>

<div class="serverp">

Click to connect!

</div></a>

</div>

</div>

<div id="textwrapper">

<div class="textblock">

<div class="servertextstyle">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a massa turpis. Vestibulum quis odio a sapien suscipit congue eget ut justo. Phasellus lectus ligula, egestas ac leo sed, lacinia convallis mi. Nam dapibus, purus a iaculis vulputate. Nam dapibus, purus.
</div>

</div>

<div class="blockdivider">

</div>

<div class="textblock">

<div class="servertextstyle">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a massa turpis. Vestibulum quis odio a sapien suscipit congue eget ut justo. Phasellus lectus ligula, egestas ac leo sed, lacinia convallis mi. Nam dapibus, purus a iaculis vulputate. Nam dapibus, purus.
</div>

</div>

<div class="blockdivider">

</div>

<div class="textblock">

<div class="servertextstyle">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a massa turpis. Vestibulum quis odio a sapien suscipit congue eget ut justo. Phasellus lectus ligula, egestas ac leo sed, lacinia convallis mi. Nam dapibus, purus a iaculis vulputate. Nam dapibus, purus.
</div>

</div>

</div>

<div id="serverwrapper">

<div class="serverblock">

<div class="borderadius"><img src="img/server1.png">

</img></div>

</div>

<div class="blockdivider">

</div>

<div class="serverblock">

<div class="borderadius"><img src="img/server2.png">

</img></div>

</div>

<div class="blockdivider">

</div>

<div class="serverblock">

<div class="borderadius"><img src="img/server3.png">

</img></div>

</div>

</div>

<div id="bannerpic">

</div>

</div>

<div id="footer">

<div id="servers">

</div>

<div id="footdivider">

</div>

<div id="footlogo">

</div>

</div>

<div id="bluebar3">

</div>

</div>

</body>

</html>

网站的完整 CSS:

    html
{
height: 100%;
}

body
{
height: 100%;
background-color: white;
margin: 0px 0px 0px 0px;
background-image: url("../img/sky2.jpg");
}

a
{
text-decoration:none;
}

#wrapper
{
width:950;
height:100%;
margin:0px auto 0px auto;
-webkit-box-shadow: 0px 0px 16px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 0px 0px 16px 0px rgba(50, 50, 50, 0.75);
box-shadow: 0px 0px 16px 0px rgba(50, 50, 50, 0.75);
min-height: 1045px;
background-color: white;
}

#header
{
width: 950px;
margin: 0px auto 0px auto;
height: 200px;
}

#logo
{
width: 950px;
margin: 0px auto 0px auto;
height: 140px;
background-image: url("../img/logo.png");
background-repeat: no-repeat;
}

#bluebar1
{
width: 950px;
margin: 0px auto 0px auto;
height: 10px;
border-bottom: 1px solid rgba(86, 177, 255, 1);
background-color: rgba(103, 185, 255, 0.43);
}

#bluebar2
{
width: 950px;
margin: 0px auto 0px auto;
height: 10px;
border-top: 1px solid rgba(86, 177, 255, 1);
background-color: rgba(103, 185, 255, 0.43);
margin-top: -1px;
}

#bluebar3
{
width: 950px;
margin: 0px auto 0px auto;
height: 10px;
border-top: 1px solid rgba(86, 177, 255, 1);
background-color: rgba(103, 185, 255, 0.43);
margin-top: 1px;
}

#nav
{
width: 950px;
margin: 0px auto 0px auto;
height: 50px;
border-top: 1px solid rgba(177, 177, 177, 0.47);
}

.menubutton
{
width: 144px;
height: 48px;
background-color: white;
display: inline-block;
text-align: center;
padding-left: 5px;
padding-right: 5px;
border-right: 1px solid rgba(177, 177, 177, 0.47);
}

.lastmenubutton
{
width: 144px;
height: 48px;
background-color: white;
display: inline-block;
text-align: center;
padding-left: 5px;
padding-right: 5px;
}

/*** Menu Buttons ***/

.menustyle
{
font-family: 'Bree Serif', serif;
font-size: 18px;
color: rgb(0, 54, 80);
}

/*** ***/

#content
{
width:950px;
height:600px;
margin-top:10px;
}

#textwrapper
{
width: 950px;
height: 250px;
background-color: white;
text-align: center;
}

#serverwrapper
{
width: 950px;
height: 220px;
background-color: white;
text-align: center;
}

.textblock
{
display: inline-block;
height: 200px;
width: 250px;
background-color: azure;
margin-top: 25px;
border:1px solid rgba(177, 177, 177, 0.47);
overflow:hidden;
border-radius:5px;
}

.blockdivider
{
width:40px;
display:inline-block;
}

/* ----------------- */

#servertitlewrap
{
width: 950px;
height: 100px;
background-color: rgb(213, 213, 213);
text-align: center;
border-bottom: 1px solid rgba(177, 177, 177, 0.77);
}

.servertitle
{
display: inline-block;
height: 50px;
width: 250px;
background-color: rgba(166, 214, 255, 1);
margin-top: 25px;
border: 1px solid rgba(255, 255, 255, 1);
overflow: hidden;
border-radius: 5px;
box-shadow: 0px 0px 2px 0px rgba(50, 50, 50, 0.75);
}

.servertitlediv
{
width:40px;
display:inline-block;
}

.servertitlefont
{
font-family: 'Bree Serif', serif;
font-size:18px;
margin-top:4px;
color: rgb(0, 54, 80);
}

.serverp
{
font-family: 'Droid Sans', sans-serif;
font-size:12px;
color: dimgray;
}

/* ----------------- */

.serverblock
{
display: inline-block;
height: 160px;
width: 250px;
background-color: azure;
margin-top: 25px;
border: 1px solid rgba(107, 107, 107, 1);
overflow: hidden;
border-radius: 5px;
box-shadow: 0px 0px 10px 0px rgba(50, 50, 50, 0.75);
}

#bannerpic
{
width:950px;
height:100px;
border-top: 1px solid rgba(177, 177, 177, 0.47);
border-bottom: 1px solid rgba(177, 177, 177, 0.47);
}

#footer
{
height: 152px;
width: 950px;
margin-top:70px;
}

#servers
{
width: 300px;
height: 150px;
background-color: rgba(166, 214, 255, 1);
border-right: 1px solid rgba(177, 177, 177, 0.47);
margin-top: 3px;
display: inline-block;
}

#footlogo
{
width: 300px;
height: 150px;
background-color: rgba(166, 214, 255, 1);
border-left: 1px solid rgba(177, 177, 177, 0.47);
margin-top: 3px;
display: inline-block;
}

#footdivider
{
width: 340px;
height: 150px;
display: inline-block;
}

.servertextstyle
{
padding: 15px;
text-align: justify;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
}

.borderadius
{
border-radius:5px;
}

最佳答案

THIS你想做什么?我更改并添加了一些 CSS。我把 display:inline-block 放在 nav 上

#nav{
display:inline-block;
}

并添加

.menubutton{
float:left;
}

关于html - 在导航栏中向菜单添加文本会关闭按钮。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23732891/

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