gpt4 book ai didi

html - 如何通过在html中绘制垂直线来垂直分隔页面

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

我是 html 的新手,我试图用垂直线找到垂直分隔的网页,但找不到我发现它们中的大多数都将宽度初始化为 50% 和 50% 或其他值。如下所示。

<div id="left" style="float:left; width:15%;" > This is left panel </div>
<div id="right" style="float:left; width:85%;"> This is right panel </div>

但是,我想在两个面板之间做一条垂直线。

我该怎么做?谢谢

编辑:

.head {
background-image: url(../img/internet-of-things-ionicframework.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
##background: #000;
padding: 50px 0;
min-height: 500px;
position: relative;
}

.head-content {
position: absolute;
top: 50%;
text-align: center;
width: 100%;
}

.head-content h2 {
color: #000;
font-size: 60px;
}

.head-content p {
color: #000;
font-size: 40px;
margin-bottom: 30px;
}

.head-content .btn {
border-radius: 2px;
padding: 20px 30px;
}

main {
min-height: 500px;
padding: 50px 0;
}

footer {
padding: 30px 0;
font-size: 14px;
color: #888;
background: #222;
text-align: center;
}

body {
font-size: 18px;
line-height: 1.5;
}
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Welcome</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="/stylesheets/styles.css">
</head>

<body>
<header>
<nav class="navbar navbar-inverse">
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#" id="deploy">Deploy</a></li>
</ul>
</div>
</nav>
</header>
<div id="container" style="width:100%;">
<div id="left" style="float:left; width:15%;"> This is left panel </div>
<div id="right" style="float:left; width:85%;"> This is right panel </div>
</div>
</body>

</html>

最佳答案

您可以使用 calc() 和以下 css

div#container {
height: calc(100vh - 70px);
float: left;
}
#left,
#right {
box-sizing: border-box;
height: 100%;
}
#right{
border-left:1px solid;
}

.head {
background-image: url(../img/internet-of-things-ionicframework.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
background: #000;
padding: 50px 0;
min-height: 500px;
position: relative;
}

.head-content {
position: absolute;
top: 50%;
text-align: center;
width: 100%;
}

.head-content h2 {
color: #000;
font-size: 60px;
}

.head-content p {
color: #000;
font-size: 40px;
margin-bottom: 30px;
}

.head-content .btn {
border-radius: 2px;
padding: 20px 30px;
}

main {
min-height: 500px;
padding: 50px 0;
}

footer {
padding: 30px 0;
font-size: 14px;
color: #888;
background: #222;
text-align: center;
}

body {
font-size: 18px;
line-height: 1.5;
}
div#container {
height: calc(100vh - 70px);
float: left;
}
#left,
#right {
box-sizing: border-box;
height: 100%;
}
#right{
border-left:1px solid;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<header>
<nav class="navbar navbar-inverse">
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#" id="deploy">Deploy</a></li>
</ul>
</div>
</nav>
</header>
<div id="container" style="width:100%;">
<div id="left" style="float:left; width:15%;"> This is left panel </div>
<div id="right" style="float:left; width:85%;"> This is right panel </div>
</div>

关于html - 如何通过在html中绘制垂直线来垂直分隔页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42778477/

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