- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如何创建一个占据所有屏幕区域减去边距的布局容器?我尝试将 calc
函数与 vh
(calc(100vh-2em)) 结合使用,但无济于事。有没有一种不用 javascript 的优雅方式来做到这一点?
这同样适用于调整侧边栏的高度,因此它不会延伸到容器上。
谢谢。
@charset "UTF-8";
body {
padding: 0em;
margin: 0em;
background-color: white;
height: 100%;
}
header {padding-bottom:2em;border-bottom:1px dashed white;}
#container{margin:2em; background-color:blue;min-height:100vh; height:100%; }
#sidemenu {
opacity:0;
float: left;
position: fixed;
width: 15%;
background-color: green;
height: 100%;
overflow: scroll;
margin-right: 1em;
font-family: Consolas, "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", Monaco, "Courier New", monospace;
-o-transition: opacity .2s ease-in-out;
-ms-transition: opacity .2s ease-in-out;
-moz-transition: opacity .2s ease-in-out;
-webkit-transition: opacity .2s ease-in-out;
transition: opacity .2s ease-in-out;
}
#sidemenu:hover {opacity:1; }
aside {
line-height: 150%;
}
svg { display:block; margin:2em auto;}
aside ul {
list-style: none;
top: 10px;
left: 0px;
margin-left: 0px;
overflow: scroll;
padding-left: 1em;
}
aside p {
}
aside ul>ul>li {
font-size: 0.8em;
color: white;
}
aside a {
color: black;
}
aside h1 {
color: white;
font-weight: bold;
padding-left: 1em;
margin-left: 0em;
font-size: 1em;
}
main {
float: left;
width: 43%;
position: relative;
margin-left: 18%;
margin-right: 1%;
display: block;
background-color:red;
padding:2em;
}
titel {
vertical-align:middle;
text-align: left;
display: block;
color: rgba(0,0,0,1);
margin: 0;
padding: 0;
font-family: "Century Schoolbook L", "Times New Roman", serif;
background-color: red;
font-size: 5em;
}
.bigger {
text-shadow: 1px 1px 4px #FFF;
color: black;
}
h2 {
text-align: left;
font-size: 40px;
padding-bottom: 5px;
border-bottom: 1px solid white;
color: white;
font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.col h2 {
color: #FFF;
}
#elcuerpo {
}
.koerper:hover {
background-color: green;
transition: background-color 1s ease-in-out;
}
#tips li {
margin-bottom: 1em;
}
s
.rules:hover {
transition: background-color 1s ease-in-out;
background-color: white;
}
#sectionside {
overflow: scroll;
padding-left: 1em;
right: 5em;
position: absolute;
float: right;
width: 15%;
background-color: rgba(0,0,0,0.05);
color: white;
margin: 0px 0px 0px 0px;
height: 100%;}
#sectionside ul {
list-style: none;
}
#sectionside h2 {color:white; font-size:0.5em;}
#sectionside li {padding-bottom:2em; font-size:1.5em; font-family:Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif; display:block; margin:0 auto; }
.titel:hover {
background-color: orange;
}
.intro {
margin-top:0em;
padding-top:0em;
font-size:4em;
color: white;
text-align: left;
text-shadow: 2px 0 #000000;
}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>A Website</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container">
<aside id="sidemenu">
<svg height="100" width="100">
<circle cx="50" cy="50" r="40" stroke="black" stroke-width="1" fill="white" class="logo"/>
</svg>
<ul>
<li><a href="#Sone">Section One</a></li>
<li><a href="#Stwo">Sectino Two</a></li>
<li><a>Section Three</a></li>
<li><a>Section IV</a></li>
<li><a>Section V</a></li>
<li><a>Section V</a></li>
<ul>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
<li>Subsection</li>
</ul>
<li> <a>Section VI</a></li>
<li>Section VI</li>
</ul>
</aside>
<main>
<header>
<titel>HTML & CSS</titel>
</header>
<section id="section one">
<h2> </h2>
<p>Lorem Ipsum</p>
</section>
<div id="sectionone">
<h2>Display: Inline</h2>
<p> Display Inline will not break the Layout, it can push other elements away horizontally, but not vertically. It also can not take height or width values.
</div>
<h2>Display: Inline-Block</h2>
<p>An element set to inline-block is very similar to inline in that it will set inline with the natural flow of text (on the "baseline"). The difference is that you are able to set a width and height which will be respected.</p>
</main>
<section id="sectionside">
<h2>Rules</h2>
<ul>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
<li>Something</li>
</ul>
</section>
<div style="clear:both;"></div>
</container>
</body>
</html>
最佳答案
Calc,就像您尝试过的那样,是正确的选择。然而,有一些轻微的调整。 4em,因为你的边距在两边都是 2em。:
width:calc(100vw - 4em);
height:calc(100vh - 4em);
jsfiddle我在这里使用了 4.1em,这样我就可以有一个边框,这样更容易看到:)
关于html - 制作一个 div 拉伸(stretch)整个屏幕减去它的边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42964279/
好吧,这是最好用图像来解释的事情...... 我正在寻找一个类似于 StretchBlt 的函数,但我可以将图像复制到定义目标四个角的 Canvas 上,即将图像的梯形/四边形拉伸(stretch)绘
我为 UITextField 制作了一个自定义键盘,其中包含 18 个 UIButton。它是一个 UIView,被设置为文本字段的 inputView。 按钮是在 UIView 的 initWith
我想创建一个 UIButton,它使用可拉伸(stretch)图像作为背景图像,例如我可以轻松调整按钮大小以适应不同的标签等。 所以我创建了以下运行良好的代码: UIImage *bgImage =
我正在尝试拉伸(stretch) UIImageView 中的图像 - 但我惨败了:) 以下设置: 带有 View 和附加到该 View 的 UIImageView 的 NIB 文件。 使用IBOut
我一直在尝试使用 html Canvas ,但由于某种原因,很难让它不拉伸(stretch)东西。我试过只使用 screen.width 和 screen.height,但我通过使用 screen.a
我想拉伸(stretch)上图的左右两侧,并保持中间的箭头不拉伸(stretch)。我怎样才能做到这一点? 最佳答案 如果你不喜欢打扰 Photoshop 并且图像不需要动态调整大小,你可以使用我在
我的页脚在一个容器中有四列。它需要在容器内以与上面的内容对齐。 我的问题是我想让左栏有红色背景,但目前它不会拉伸(stretch),因为它显然在容器中。 我怎样才能将它向左拉伸(stretch)整个宽
有没有办法拉伸(stretch)按钮,使中央部分保持完整? 9-patch 不允许这样做。 编辑:我按照 Benito 的建议使用了 9-patch。它工作正常。奇怪的是,我第一次无法得到它。 最佳答
我想拉伸(stretch)上图的左右两边,中间的箭头不拉伸(stretch)。我该怎么做? 最佳答案 如果你不想打扰 Photoshop 并且如果图像不需要动态调整大小,你可以在 UIImage 上使
我创建了一个 9patch 图像,不知何故它只能垂直拉伸(stretch)。我尝试了其他 9-patch 图像,但它们具有相同的效果,为什么它们在其他情况下工作。所以我认为 9patch 应该没问题。
我需要在边框控件(或类似控件)中绘制一些简单的线条,这些线条始终延伸到边框的边界。有没有办法只拉伸(stretch)线条而不是它的笔?不涉及大量 C#? 在这个版本中,线条延伸:
这是我的 XAML 及其外观:
编辑:答案将允许背景图像根据 body 的大小改变它的高度。如果正文是 500px 高,它应该是 100% 宽度,500px 高度。或 100% 宽度 2500 像素高度。 也许我错过了这件事,但我正
我有一个 UILabel。我设置了尾随和前导空间约束,还添加了对齐 Y 中心约束。我已将行数设置为零。 我的目标是将 UILabel 拉伸(stretch)到某个最大宽度,然后添加新行。在给定的约束条
我正在制作一个网站,对于该网站,我正在使用顶部的导航栏。我想要的是将栏放在页面的顶部,并且它是主页的单独颜色。这是我当前的代码: body { font-family: "Baloo Bhaina
我编写了代码来 reshape 已纹理化的四边形。当我拉伸(stretch)四边形时,图像确实按照我的预期拉伸(stretch)了。我似乎在拉伸(stretch)图像时有两个不同的三角形,图像被拉伸(
我在 div 中嵌入了 YouTube。此 div .entry-content 的 max-width 为 30em。 YouTube 嵌入我想要全窗口宽度,延伸到 #container 之外。为此
看: //UIImageView* stretchTest = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]
我有一个 super 简单的网页,由纯 HTML/CSS 组成。正如预期的那样,当我在本地运行它时,一切正常。 但是,当我部署它时(使用 Droppages,一个通过 Dropbox 的静态页面托管平
我正在尝试将一个 9 色 block 图像设置为我的一项 Activity 的背景,但它不必要地拉伸(stretch),使一切变得奇怪。我使用 draw9patch 创建它,并在左下角添加了一个像素,
我是一名优秀的程序员,十分优秀!