我正在努力完成这项我正在做的项目。我在创新云计划方面遇到了麻烦。请解释我如何解决这个问题。
我无法让“了解更多”按钮位于标题部分的段落下方。
我无法将主要部分中的图像浮动到标题和段落的左侧。
我也无法管理jumbotron DIV出现在主要下方。图像与main融合,它不会出现在它应该的位置下方。
以下是视觉笔:http://codepen.io/alejoj/pen/xGBbwv
感谢您的帮助。
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-dao</artifactId>
<version>2.0.3</version>
</dependency>
html, body {
margin: 0;
padding: 0;
}
body {
font-family: 'Roboto', sans-serif;
font-weight: 100;
}
.container {
margin: 0 auto;
max-width: 940px;
padding: 0 10px;
}
/* Header */
.header {
height: 800px;
text-align: center;
background-image: url('https://s3.amazonaws.com/codecademy-content/projects/innovation-cloud/bg.jpg');
background-size: cover;
}
.header .container {
position: relative;
top: 200px;
}
.header h1 {
font-size: 80px;
line-height: 100px;
margin-top: 0;
margin-bottom: 80px;
color: white;
}
@media (min-width:850px) {
.header h1 {
font-size: 120px;
}
}
.header p {
font-weight: 500;
letter-spacing: 8px;
margin-bottom: 40px;
margin-top: 0;
color: white;
}
.btn{
width: 30%;
height: 40px;
border: none;
margin: 25px auto 0 auto;
font-family: 'Roboto', sans-serif;
font-size: 15px;
background-color: black;
color: white;
}
.btn:hover {
background: #117bff;
cursor: pointer;
transition: background .5s;
}
/* Nav */
.nav{
background-color: black;
}
.nav ul {
display: table;
list-style: none;
margin: 0 auto;
padding: 30px 0;
text-align: center;
}
.nav li{
display: cell;
vertical-align: middle;
float: left;
padding-left: 10px;
color: white;
font-family: 'Roboto', sans-serif;
}
/* Main */
.main .container {
margin: 80px auto;
}
.main h2, p{
display: inline-block;
float: left;
}
.main img{
height: 150px;
width: 35%%;
margin: 50px -5px 50px 0px;
display: inline-block;
float: left;
}
/* Jumbotron */
.jumbotron {
margin: 10px 0;
height: 600px;
text-align: right;
background-image:url('https://s3.amazonaws.com/codecademy-content/projects/innovation-cloud/jumbotron_bg.jpg');
}
.jumbotron .container {
position: relative;
top: 220px;
}
/* Footer */
.footer {
font-size: 14px;
}
/* Media Queries */
@media (max-width: 500px) {
.header h1 {
font-size: 50px;
line-height: 64px;
}
.clearfix{
clear: both;
}
.main, .jumbotron {
padding: 0 30px;
}
.main img {
width: 100%;
}
}
答案 0 :(得分:1)
不完全确定你想要的结果,但似乎这个css丢掉了很多想要解决的问题:
.main h2, p {
display: inline-block;
float: left;
}
如果删除它并将图像上的右边距从-5更改为50,它看起来非常好:http://codepen.io/anon/pen/BNbyEP
如果您不清楚&#34;清除&#34;浮动元素可以真正抛弃您的布局花车。有时我会添加一个br style =&#34; clear:both&#34;在浮动元素之后保持流动看起来像预期的那样(在没有看到你的jumbotron图像应该在哪里)
答案 1 :(得分:-1)
p
设置为inline-block
。删除这个:
.main h2, p {
display: inline-block;
float: left;
}
margin: 50px -5px 50px 0px;
至:
margin: 50px 50px 50px 0px;