- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在下面的代码中,
<style type="text/css">
#header{
height: 20px;
background-color: #2A646C;
width: 50%;
margin: auto;
}
#container{
display:flex;
flex-wrap: wrap;
border: 2px solid red;
width: 50%;
margin: auto;
padding: 10px;
background-color: #C4D8E2;
}
#container1{
border: 2px solid yellow;
width: 100%;
background-color: #C4D8E2;
}
#container1 p span{
background-color: #C4D8E2;
color: #5D8AA8;
font-family: sans-serif;
font-size: 12px;
}
#container1 h3{
background-color: #C4D8E2;
}
#container2{
border: 2px solid blue;
width: 45%;
background-color: #C4D8E2;
margin-right: 8%;
display:flex;
flex-wrap: wrap;
}
#container2 form{
width: 100%;
height: 100%;
}
#container2 p{
width:100%;
}
#container2 span{
font-weight: bold;
font-family: "Times New Roman";
font-size: 16px;
}
#container2 #span1{
color: #5D8AA8;
margin-right: 5px;
}
#container2 #span2{
color: #5072A7;
}
#container2 input[type=submit]{
border: 1px solid black;
width: 25%;
height: 40%;
margin-left: 68%;
background-color: #C4D8E2;
}
#container3{
border: 2px solid green;
width: 45%;
background-color: #5072A7;
color: white;
}
#container3 form{
width: 100%;
height: 100%;
}
#container3 input[type=submit]{
border: 2px solid orange;
background-color: #5072A7;
width: 25%;
height: 10%;
margin-left: 68%;
}
#container3:nth-child(10){
font-size: 14px;
}
#container3:nth-child(16){
display: inline-block;
font-size: 10px;
font-style: underline;
margin-left: 68%;
}
</style>
<div id="header"></div><br><br>
<div id="container">
<div id="container1">
<h3>Enter the system</h3>
<p><span>It is necessary to login in Your account in order to sign up for a course.</span></p>
</div>
<div id="container2">
<p><span id="span1">ARE YOU NEW?</span><span id="span2">REGISTER</span></p>
<form method="POST" action="javascript:void(0)" enctype="multipart/form-data">
<input type="text" name="username" required placeholder="User name" autocomplete="off"
pattern="^[A-Za-z0-9._-]{6,10}$" size="40" maxlength="10">
<br><br>
<input type="email" name="emailid" required placeholder="Email" autocomplete="off"
pattern="^[A-Za-z0-9 _.-]+@[A-Za-z.-]+\.[A-Za-z]{3,4}$" size="40" maxlength="30">
<br><br>
<input type="password" name="password" required placeholder="Password" autocomplete="off"
pattern="^[A-Za-z0-9 _.-]{8,15}$" size="40" maxlength="15">
<br><br>
<input type="password" name="confirmpassword" required placeholder="Confirm Password"
pattern="^[A-Za-z0-9 _.-]{8,15}$" size="40" maxlength="15" autocomplete="off">
<br><br>
<input type="submit" name="register" value="Register">
</form>
</div>
<div id="container3">
<form method="POST" action="javascript:void(0)" enctype="multipart/form-data">
<p><span class="span3">ALREADY A STUDENT?</span><span class="span4">LOGIN</span></p>
<br><br>
<input type="text" name="loginname" required placeholder="User name" autocompleter="off"
pattern="^[A-Za-z0-9._-]{6,10}$" size="40" maxlength="10">
<br><br>
<input type="password" name="loginpassword" required placeholder="Password" autocompleter="off"
pattern="^[A-Za-z0-9 _.-]{8,15}$" size="40" maxlength="15">
<br><br>
<input type="checkbox" name="remember" value="yes" id="remember"><label for="remember">Remember me?</label>
<br><br>
<input type="submit" name="login" value="Login" id="loginbutton">
<br>
<label>Forgotpassword?</label>
</form>
</div>
</div>
1) container2
或 container3
大小在包含额外元素后不会增加高度,为什么?
2) 如何使用 nth-child
来选择 container3
的最后两个标签?
最佳答案
1)
container2
orcontainer3
size does not increase after including additional elements, why?
因为您将整个容器的宽度限制为 width: 50%
。
DEMO 1 (您的原始代码,未更改)
试试这个调整:
#container{
display:flex;
flex-wrap: wrap;
border: 2px solid red;
min-width: 50%; /* adjusted */
margin: auto;
padding: 10px;
background-color: #C4D8E2;
}
2) How do I use nth-child to pick last two labels of container3?
#container3 > form > label:nth-last-of-type(1) { font-weight: bold; color: red; }
#container3 > form > label:nth-last-of-type(2) { font-weight: bold; color: aqua; }
引用:http://www.w3.org/TR/css3-selectors/#selectors
DEMO 2 的替代方案...
如果您不想改变整个 flex 容器的宽度约束,您可以使表单成为 flex 容器,这会将表单元素限制在容器的边界内。
所以不是这个(如上所述):
#container{
display:flex;
flex-wrap: wrap;
border: 2px solid red;
min-width: 50%; /* adjusted */
margin: auto;
padding: 10px;
background-color: #C4D8E2;
}
试试这个:
#container2 form{
width: 100%;
height: 100%;
display: flex; /* new */
flex-direction: column; /* new */
}
#container3 form{
width: 100%;
height: 100%;
display: flex; /* new */
flex-direction: column; /* new */
}
更新(基于评论和修改后的问题)
使用 DEMO 4 ,我们可以改进提交按钮的显示:
#container2 input[type=submit]{
border: 1px solid black;
/* width: 25%; */
height: 40%;
/* margin-left: 68%; */
background-color: #C4D8E2;
/* new */
margin-left: auto;
margin-right: 5%;
width: 75px;
}
#container3 input[type=submit]{
border: 2px solid orange;
background-color: #5072A7;
/* width: 25%; */
height: 10%;
/* margin-left: 68%; */
/* new */
margin-left: auto;
margin-right: 5%;
width: 75px;
}
关于html - flex 盒子尺寸不会增加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34427219/
这个问题在这里已经有了答案: CSS3 Flexbox: display: box vs. flexbox vs. flex (3 个答案) 关闭 1 年前。 今天我们中的许多人都知道 displa
$('.finalLink').html(" Click to Follow"); 我正在尝试创建一个以 super 框模式打开的链接。尝试了灯箱,结果相同。这些链接有效,但只是转到该网站。如果我静态
我使用了 RayHandler.useDiffuseLight(true) ,现在无论我设置什么环境光值,屏幕上未照亮的部分都是黑色的。这是正常的吗?我见过其他用 libgdx 制作的应用程序,它同时
我需要帮助解决一个简单的问题。我的任务即将结束,我们要制作不同的艺术人物。我制作了一个“正方形内的正方形”盒子,需要生成该盒子的 4 行和 4 列。 我认为最好的解决方案是多一些 for 循环,但不能
我怎样才能实现this effect使用 CSS 和/或 jQuery? 我会发布到目前为止我编写的代码,但它没有用...... 最佳答案 使用jQuery Masonry或Isotope为了达成这个
我写了下面的代码: for row in range(len(listOfLists)): print('+' + '-+'*len(listOfLists)) print('|',
我想知道如何在 CSS3 中制作成 Angular 盒子。喜欢这个网站: http://themeluxe.com/themes/glissando/ (白人) 我怎样才能使边框看起来更好、更平滑。
我正在尝试实现具有三个垂直部分的简单布局: 页面顶部的小标题。 主要内容,必要时展开,以便页脚保留在页面底部。 页面底部的页脚。 主要内容部分应进一步分为两部分:一个带有输入框和按钮的非常小的表单,以
我正在尝试构建如下图所示的网格 IMG 链接:http://postimg.org/image/qo3b4nof1/ 但我得到的 DIV E 几乎在 D-DIV 旁边 这是我的代码
如何修改fancybox盒子的定位?我希望它被定位,以便它漂浮在我的容器 div 中... 感谢您的宝贵时间和帮助! 最佳答案 jquery.fancybox-1.2.6 的第 255 行有这段代码
这个问题在这里已经有了答案: Inset border-radius with CSS3 (8 个答案) 关闭 9 年前。 border-radius 属性可以使盒子的 Angular 变圆。但是如
我创建了一个包装器元素,其中包含 2 个彼此相邻的行内 block 框(图片中为浅绿色和黄色)。然后我创建了另外两个 div,它们都嵌套在其中一个内联 block 中以使内容居中。它可以工作,但由于某
我在使用 WordPress 时遇到问题,在盒子中嵌套盒子。在 WordPress 之外,这工作正常。我确定只有一两个参数有误。 外框为dp23,内框为dp22由于某种原因,内框 (dp22) 之间存
我目前尝试在容器内排列盒子的结果是这样的输出。 但我想要实现的是, 用最大数量的框填充每一行,但每个框都有固定的填充和边距。我相信我已经做到了。 我需要每行中的单个框来覆盖剩余空间,间隙仅为 1 像素
我在下面有多个 flexbox 的代码。当页面展开时,我如何将它们垂直居中放置在页面中?我尝试在我的 flex-container 中使用 justify-content: center; 但当我使用
我有这样的布局: 我
我是编程新手,我注意到有人提到了 flex box。在阅读了很多相关内容之后,它似乎对我有用。唯一的问题是我在安装它时遇到了很多麻烦,即使在搜索了大约一个小时的帮助之后也是如此。我从 github 下
Vagrantfile有问题: # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config
我正在尝试下载一个 Vagrant 的盒子,但他们的服务器此时非常缓慢。他们有公共(public)镜子吗?我想下载precision64.box 文件。 谢谢 最佳答案 尝试更可靠的: Vagrant
在一个父容器内,三个 div 彼此重叠。顶部 div 是固定高度。底部 div 的内容占用了未知数量的垂直空间,但需要显示其中的所有内容。顶部 div 应填充剩余的垂直空间。每一个 // 100%
我是一名优秀的程序员,十分优秀!