html - 使用 aside which float right 并仅使用 css 覆盖整个页面?

标签 html css

我正在尝试制作这样的页面 img .目前我正在处理这个侧边栏,因为我需要使用 HTML5,所以我认为 aside 元素是一个不错的选择。但是我无法像图片中那样定位它。 aside 是好的选择还是如何以其他方式解决?这是我的 html

<section id = "overview"></section>
<aside>
    <h1>Serverstatus:</h1>
    <div id ="benutzerContainer">
        <h2 class = "firstLine">Benutzer</h2>
        <p class = "firstLine">Administrator</p>
    </div>
    <div id = "zeitContainer">
        <h2 class = "secondLine">Systemstartzeit</h2>
        <p class = "secondLine">10:00</p>
    </div>
    <div id = "datumContainer">
        <h2 class = "thirdLine">Systemstartdatum</h2>
        <p class = "thirdLine">06.03.2017</p>
    </div>
    <div id ="loginContainer">
        <h2 class ="fourthLine">Fehlgeschlagene <br />
        Logins</h2>         
        <p class ="fourthLine">3</p>
    </div>
    <aside>

和CSS

section#overview{
width: 100%
background: linear-gradient(to bottom, rgba(206,206,206,0.3),      rgba(206,206,206,1)); 

}
aside {
float: right;
width: 25%;
background: linear-gradient(to bottom, rgba(206,206,206,0.3), rgba(206,206,206,1));
}

我无法在向右浮动时使高度达到 100%。只要我把 position: absolute 放在左边,即使是 float 也被设置到右边。

最佳答案

我有点不明白你想要什么,但这就是你想要的吗?

body {
  background: linear-gradient(to bottom, rgba(206, 206, 206, 0.3), rgba(206, 206, 206, 1));
}

* {  box-sizing: border-box;  }

section#overview {
  width: 75%;
  height: 100%;
  border-right: 1px #ccc solid; /* Switch if overview if taller */
  float: left;
}

aside {
  float: right;
  width: 25%;
  height: 100%;
  border-left: 1px #ccc solid;
}
<section id="overview">
  afwef foawjp foij oaijfw eoijfpa ojifojiaepo ijfapo jifpeo jiafwo f oijapojiefoajfweojifapofjiep ojioi jofiajpoj foajwejiawj ofji ofjawoj pofja oifjaeo jfaoji ojfaowj ofij ojfoawij pofijaw pofijawepoj 
</section>
<aside>
  <h1>Serverstatus:</h1>
  <div id="benutzerContainer">
    <h2 class="firstLine">Benutzer</h2>
    <p class="firstLine">Administrator</p>
  </div>
  <div id="zeitContainer">
    <h2 class="secondLine">Systemstartzeit</h2>
    <p class="secondLine">10:00</p>
  </div>
  <div id="datumContainer">
    <h2 class="thirdLine">Systemstartdatum</h2>
    <p class="thirdLine">06.03.2017</p>
  </div>
  <div id="loginContainer">
    <h2 class="fourthLine">Fehlgeschlagene <br />
        Logins</h2>
    <p class="fourthLine">3</p>
  </div>
  <aside>

关于html - 使用 aside which float right 并仅使用 css 覆盖整个页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42985795/

相关文章:

javascript - 将鼠标悬停在下拉菜单上时,如何让导航栏的下拉菜单保持不变?

c# - 在 asp.net 中将变量数据与 div 标签集成

html - 鼠标悬停之前文本模糊?

jquery - 页面滚动时div消失

javascript - React Style Prop 不反射(reflect)在 IE 中

html - CSS 两侧边框底部 1px 太长

html - 用于调整图像大小的 CSS

html - 通过 css 重新排序元素

javascript - 如何确定哪些元素在溢出的 <div> 中可见

javascript - HTML 或 CSS 导航栏问题