我创建了一个容器来保留我的段落,但是我似乎无法让它在容器的左侧一路启动。它从左侧开始像100px一样。我找不到我在做错什么。
body{
overflow: hidden;
background-color: #1C213D;
background-image: url("background.png");
}
.nav{
position: absolute;
width: 250px;
height: 5000px;
background-color: rgba(0, 0, 0, .2);
border: 2px solid rgba(56, 179, 206, .4);
}
.nav-pills li a{
/* 0.5s is the amount of time it take to change colors */
transition: .3s background ease-in-out;
}
ul li{
position: relative;
text-align: center;
list-style: none;
font-family: "Play";
display: block;
color: lightsteelblue;
margin-top: 200px;
font-size: 20px;
padding: 10px;
}
.main{
}
p{
padding-top: 10px;
padding-bottom: 10px;
text-align: left;
font-size: 18px;
color: whitesmoke;
}
.container{
position: absolute;
width: 800px;
height: 450px;
margin-top: 200px;
margin-left: 265px;
background-color: rgba(0, 0, 0, .8);
border-top: 2px solid rgba(56, 179, 206, 1);
border-bottom: 2px solid rgba(56, 179, 206, 1);
border-right: 2px solid rgba(56, 179, 206, 1);
}
img{
position: absolute;
margin-left: 54px;
margin-top: 25px;
}
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Play" rel="stylesheet">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Home</title>
</head>
<body>
<div class="container-fluid">
</div>
<div class="container-fluid">
<div class="col-md-4 col-lg-4 col-sm-4 col-xs-4">
<ul class="nav nav-pills nav-stacked" role="tablist">
<img src="logo.png">
<li class="active"><a href="home.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="projects.html">Projects</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div class="container">
<div class="col-md-7 col-lg-7 col-xs-7 col-sm-7 col-lg-offset-1 col-md-offset-1 col-sm-offset-1 col-xs-offset-1 main">
<p>This is the home page.</p>
</div>
</div>
</div>
</body>
</html>
.col-[size]-offset
类将创建该偏移。删除它们,段落将在左侧开始。
body{
overflow: hidden;
background-color: #1C213D;
background-image: url("background.png");
}
.nav{
position: absolute;
width: 250px;
height: 5000px;
background-color: rgba(0, 0, 0, .2);
border: 2px solid rgba(56, 179, 206, .4);
}
.nav-pills li a{
/* 0.5s is the amount of time it take to change colors */
transition: .3s background ease-in-out;
}
ul li{
position: relative;
text-align: center;
list-style: none;
font-family: "Play";
display: block;
color: lightsteelblue;
margin-top: 200px;
font-size: 20px;
padding: 10px;
}
.main{
}
p{
padding-top: 10px;
padding-bottom: 10px;
text-align: left;
font-size: 18px;
color: whitesmoke;
}
.container{
position: absolute;
width: 800px;
height: 450px;
margin-top: 200px;
margin-left: 265px;
background-color: rgba(0, 0, 0, .8);
border-top: 2px solid rgba(56, 179, 206, 1);
border-bottom: 2px solid rgba(56, 179, 206, 1);
border-right: 2px solid rgba(56, 179, 206, 1);
}
img{
position: absolute;
margin-left: 54px;
margin-top: 25px;
}
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Play" rel="stylesheet">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Home</title>
</head>
<body>
<div class="container-fluid">
</div>
<div class="container-fluid">
<div class="col-md-4 col-lg-4 col-sm-4 col-xs-4">
<ul class="nav nav-pills nav-stacked" role="tablist">
<img src="logo.png">
<li class="active"><a href="home.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="projects.html">Projects</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div class="container">
<div class="col-md-7 col-lg-7 col-xs-7 col-sm-7 main">
<p>This is the home page.</p>
</div>
</div>
</div>
</body>
</html>
- 首先,您的Bootstrap文件不正确包含附加 http:在bootstrap链接之前。
- 删除偏移类以获取左侧的段落
body{
overflow: hidden;
background-color: #1C213D;
background-image: url("background.png");
}
.nav{
position: absolute;
width: 250px;
height: 5000px;
background-color: rgba(0, 0, 0, .2);
border: 2px solid rgba(56, 179, 206, .4);
}
.nav-pills li a{
/* 0.5s is the amount of time it take to change colors */
transition: .3s background ease-in-out;
}
ul li{
position: relative;
text-align: center;
list-style: none;
font-family: "Play";
display: block;
color: lightsteelblue;
margin-top: 200px;
font-size: 20px;
padding: 10px;
}
.main{
}
p{
padding-top: 10px;
padding-bottom: 10px;
text-align: left;
font-size: 18px;
color: whitesmoke;
}
.container{
position: absolute;
width: 800px;
height: 450px;
margin-top: 200px;
margin-left: 265px;
background-color: rgba(0, 0, 0, .8);
border-top: 2px solid rgba(56, 179, 206, 1);
border-bottom: 2px solid rgba(56, 179, 206, 1);
border-right: 2px solid rgba(56, 179, 206, 1);
}
img{
position: absolute;
margin-left: 54px;
margin-top: 25px;
}
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Play" rel="stylesheet">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Home</title>
</head>
<body>
<div class="container-fluid">
</div>
<div class="container-fluid">
<div class="col-md-4 col-lg-4 col-sm-4 col-xs-4">
<ul class="nav nav-pills nav-stacked" role="tablist">
<img src="logo.png">
<li class="active"><a href="home.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="projects.html">Projects</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</div>
<div class="container">
<div class="col-md-7 col-lg-7 col-xs-7 col-sm-7 main">
<p>This is the home page.</p>
</div>
</div>
</div>
</body>
</html>
是那些 col-xx-offset-1
'。如果删除这些,则您的文字坐在左侧(当然要填充填充和.container
)。
更正的代码:
<div class="container">
<div class="col-md-7 col-lg-7 col-xs-7 col-sm-7 main">
<p>This is the home page.</p>
</div>
</div>