html - 为什么我的框没有出现在我的部分中?

标签 html css

我不明白为什么我创建的框没有出现在我的部分中。我上面有一个幻灯片,但我认为它不会影响它。我已经检查过它的尺寸是否适合该部分,但它出现在正下方。 What it looks like

这是我的 HTML:

#main {
  clear: both;
  width: 960px;
  height: 350px;
  background-color: #7EFFF7;
}

.gojima {}

.article1 {
  float: right;
  display: inline-block;
  background: -moz-linear-gradient(top, #77ebcf 20%, #ffffff 20%);
  /* FF3.6-15 */
  position: relative;
  border-top-style: solid;
  border-right-style: solid;
  border-bottom-style: solid;
  border-color: #e1e1e1;
  height: 295px;
  width: 650px;
  margin-right: 0px;
}

.article1 h1 {
  font-size: 30px;
  text-align: center;
  position: relative;
  bottom: 15px;
  font-family: 'Economica', sans-serif;
}

.article1 p {
  font-size: 20px;
  padding-left: 15px;
  padding-top: 10px;
  padding-right: 15px;
  font-family: 'Playfair Display', serif;
}

#main2 {
  clear: both;
  width: 960px;
  height: 350px;
  background-color: #000;
}
<section id="main">
  <div class="gojima">
    <a href="#"><img src="images/pic1.jpg" alt="hp1" width="300" height="300" /></a>
  </div>

  <div class="article1">
    <h1> THE RICE BURGER TREND</h1>
    <p>Guess what? Burger nerds stuck in an unending "brioche vs milk bun" argument now have a new topic to battle: the bun-free burger. They can test out the merits of this trend at Gojima, Sydney's first rice burger bar, which opened at The Star.</p>
  </div>

</section>


<section id="main2">
  <div class="mbassy">
    <a href="#"><img src="images/pic2.jpg" alt="hp2" width="300" height="300" /></a>
  </div>

  <div class="article2">
    <h2> THE LOCAL EMBASSY BOILER-ROOM</h2>
    <p> On a bright corner of Wattle Street in Ultimo is a busy cafe, The Local Mbassy. Soft music from the ‘20s plays and locals enjoy the view across Wentworth Park, tucking into burgers, pancakes and pans of baked eggs and sipping on Campos coffee.</p>
  </div>

</section>

最佳答案

您需要将 .gojima 向左浮动,以便让其他内容位于其旁边。您也可能不需要 .article1 上的 float:right

#main {
  clear: both;
  width: 960px;
  height: 350px;
  background-color: #7EFFF7;
}

.gojima {
  float: left;
}

.article1 {
  float: right;
  display: inline-block;
  background: -moz-linear-gradient(top, #77ebcf 20%, #ffffff 20%);
  /* FF3.6-15 */
  position: relative;
  border-top-style: solid;
  border-right-style: solid;
  border-bottom-style: solid;
  border-color: #e1e1e1;
  height: 295px;
  width: 650px;
  margin-right: 0px;
}

.article1 h1 {
  font-size: 30px;
  text-align: center;
  position: relative;
  bottom: 15px;
  font-family: 'Economica', sans-serif;
}

.article1 p {
  font-size: 20px;
  padding-left: 15px;
  padding-top: 10px;
  padding-right: 15px;
  font-family: 'Playfair Display', serif;
}

#main2 {
  clear: both;
  width: 960px;
  height: 350px;
  background-color: #000;
}
<section id="main">
  <div class="gojima">
    <a href="#"><img src="images/pic1.jpg" alt="hp1" width="300" height="300" /></a>
  </div>

  <div class="article1">
    <h1> THE RICE BURGER TREND</h1>
    <p>Guess what? Burger nerds stuck in an unending "brioche vs milk bun" argument now have a new topic to battle: the bun-free burger. They can test out the merits of this trend at Gojima, Sydney's first rice burger bar, which opened at The Star.</p>
  </div>

</section>


<section id="main2">
  <div class="mbassy">
    <a href="#"><img src="images/pic2.jpg" alt="hp2" width="300" height="300" /></a>
  </div>

  <div class="article2">
    <h2> THE LOCAL EMBASSY BOILER-ROOM</h2>
    <p> On a bright corner of Wattle Street in Ultimo is a busy cafe, The Local Mbassy. Soft music from the ‘20s plays and locals enjoy the view across Wentworth Park, tucking into burgers, pancakes and pans of baked eggs and sipping on Campos coffee.</p>
  </div>

</section>

关于html - 为什么我的框没有出现在我的部分中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44310854/

相关文章:

html - 如何防止折叠此子元素?

php - 从 url 中删除目录名称? (example.org/folder1/file 到 example.org/file)

html - Firefox CSS Float 和 NoWrap 错误

html - 如何在 HTML 中显示原始 rgb 图像

php - 有什么解决方案可以在 laravel Blade 上操作 MySQL 数据库中包含的超链接吗?

javascript - 如何获取html对象将其作为AngularJS中的变量传递

javascript - history.back 后 Chrome 重新加载页面

javascript - jquery ui 将可拖动元素限制在较小的容器内

javascript - 背景颜色从下到上悬停动画

Css:将图像紧靠在标题和副标题的右侧