需要使底部的三个div浮动到右侧

时间:2018-10-19 15:44:15

标签: html css

除了我在这里发布的代码外,还有更多的代码,但这是我当前代码的基本设置,我需要让.sidebar(一个div中的三个div)浮动到container_body的右侧。当我将.sidebar放在页面顶部时,浮动功能起作用了,但是我将其移到了底部,因为它需要在移动视图上显示在页面的底部。因此,如果有解决方案,那也可以工作,但是现在我试图将主体移到左侧,然后将这三个div移到右侧,并在滚动时保持粘性。

body {
  width: 100%;
}

.container {
  width: 1140px;
}

.container_body {
  width: 800px;
  margin: 0px 24px 24px 24px;
  overflow: none;
}

.amenities {
  height: 260px;
}

.amenities-wrapper {
  margin-top: 80px;
}

.panel-main {
  margin-left: 0px !important;
}

.sidebar {
  float: right;
  width: 245px;
}

.sidebar-sticky {
  position: sticky;
  float: right;
}

.sidebar-sticky2 {
  position: sticky;
  float: right;
}

.sidebar-sticky3 {
  position: sticky;
  float: right;
}

.clear {
  clear: both;
  float: none;
}
<div class="container mobile" style="margin-top: 100px">
  <div class="container_body">
    <div class="header">
      <h1>Header</h1>
    </div>

    <div class="amenities-wrapper">
      <h3>Amenities & Services</h3>
      <div class="amenities">
        <img src="wifi.png" alt="WiFi" />Wifi
        <img src="parking.png" alt="Parking" />Parking
      </div>
    </div>

    <div class="pricechart">
      <h3>Different price options</h3>
      <div class="pricechart-table">
        <div class="pricechart-hourly-header">
          <h5>Hourly</h5>
        </div>
        <p>Available now</p>
      </div>
      <div class="pricechart-table">
        <div class="pricechart-daily-header">
          <h5>Daily</h5>
        </div>
        <p>Available now</p>
      </div>
      <div class="pricechart-table">
        <div class="pricechart-weekly-header">
          <h5>Weekly</h5>
        </div>
        <p>Available now</p>
      </div>
    </div>

    <div class="reservation-schedule">
      <h3>Current Availability</h3>
    </div>
  </div>

  <div class="sidebar">
    <div class="sidebar-sticky">
      <div class="office-reservation">
        <div class="panel-main panel-primary">
          <h3>Office Reservation</h3>
        </div>
      </div>
    </div>

    <div class="sidebar-sticky2">
      <div class="panel-main panel-primary">
        <h3>Questions</h3>
      </div>
    </div>

    <div class="sidebar-sticky3">
      <div class="panel-main panel-primary">
        <h3>Contact Information</h3>
      </div>
    </div>
  </div>
</div>

0 个答案:

没有答案