在本文中,我们将给您介绍关于框中框+文本,页面HTML/CSS对齐的详细内容,并且为您解答html框框居中的相关问题,此外,我们还将为您提供关于ASP.NETMVC中@Html.Partial,@Ht
在本文中,我们将给您介绍关于框中框 + 文本,页面 HTML/CSS 对齐的详细内容,并且为您解答html框框居中的相关问题,此外,我们还将为您提供关于ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处、asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction、CS50 HTML 和 CSS 基础 (介绍最简单的 HTML 和 CSS)的知识。
本文目录一览:- 框中框 + 文本,页面 HTML/CSS 对齐(html框框居中)
- ASP.NET MVC 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction
- asp.net – Html.Partial vs Html.RenderPartial&Html.Action vs Html.RenderAction.任何人都可以描述不同之处
- asp.net 中@Html.Partial,@Html.Action,@Html.RenderPartial,@Html.RenderAction
- CS50 HTML 和 CSS 基础 (介绍最简单的 HTML 和 CSS)
框中框 + 文本,页面 HTML/CSS 对齐(html框框居中)
如何解决框中框 + 文本,页面 HTML/CSS 对齐
我需要将文本排列在框中,两个并排的框,每个框的右上角都有一个标题类型的元素。这就是我到目前为止所想到的:做我想要的,但看起来很难看,因为它有点不对齐。什么是更好的方法呢?虽然没有引导。
p {
border: 1px solid black;
}
#p1 {
width: 60px;
height: 20px;
background-color: Orange;
font-size: large;
float: right;
}
#p2 {
border: 1px solid black;
background-color: DodgerBlue;
}
#dogerBox {
border: 1px solid black;
background-color: DodgerBlue;
}
div+p {
width: 40px;
height: 80px;
background-color: Orange;
font-size: large;
float: right;
}
#first {
width: 330px;
height: 250px;
background: LightBlue;
overflow: visible;
border: 1px solid black;
}
#first #headers {
position: relative;
width: 20%;
height: 7%;
margin: auto;
margin-bottom: 65%;
background: Orange;
left: 6px;
float: right;
border: 1px solid black;
margin: 1px;
}
#second {
width: 330px;
height: 250px;
background: LightBlue;
overflow: hidden;
border: 1px solid black;
position: relative;
left: 332px;
bottom: 252px;
margin: 1px;
}
#second #headers {
position: relative;
width: 20%;
height: 7%;
margin: auto;
margin-bottom: 65%;
background: Orange;
left: 6px;
float: right;
border: 1px solid black;
}
<div id="first">
<div id="headers"> First Box </div>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters,as opposed to using ''Content here,content here'',making it look like readable English. Many desktop publishing packages and web page editors Now use Lorem Ipsum as their default model text,and a search for ''lorem ipsum'' will uncover many web sites still in their infancy. VarIoUs versions
have evolved over the years,sometimes by accident,sometimes on purpose (injected humour and the like).
</div>
<div id="second">
<div id="headers"> Second Box</div>
Contrary to popular belief,Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC,making it over 2000 years old. Richard Mcclintock,a Latin professor at Hampden-Sydney College in Virginia,looked up
one of the more obscure Latin words,consectetur,from a Lorem Ipsum passage,and going through the cites of the word in classical literature,discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum
et Malorum" (The Extremes of Good and Evil) by Cicero,written in 45 BC. This book is a treatise on the theory of ethics,very popular during the Renaissance. The first line of Lorem Ipsum,"Lorem ipsum dolor sit amet..",comes from a line in section
1.10.32.
</div>
<div>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters,sometimes on purpose (injected humour and the like).
</div>
解决方法
我强烈建议您使用 css-grid 或 flexbox 来实现现代方法。在这种情况下,css-grid 是更好的方法,因为它可以同时控制高度和宽度。
为此,我将您的 2 个盒子包装在另一个带有 class 的 div 中:grid-wrapper
。 我使用以下命令将该框更改为网格系统:display: grid;
。 要获得 2 列,请使用:grid-template-columns: repeat(2,1fr);
。如果您想要 3 列,请将 2 更改为 3 或您喜欢的任何数字以获得更多。 要分隔这些框,您可以使用:grid-gap
。
我想让您知道的一件事:您两次使用 ID #header
导致 HTML 使用无效。 ID 必须是唯一的。总是!因此,我将其更改为一个类。
body {
margin: 0;
}
.grid-wrapper {
display: grid;
grid-template-columns: repeat(2,1fr);
grid-gap: 10px;
padding: 10px;
}
#first,#second {
background: LightBlue;
border: 1px solid black;
padding: 10px;
}
.headers {
width: 40%;
height: auto;
margin: -8px -8px 0.2em 0.2em;
background: Orange;
float: right;
border: 1px solid black;
text-align: center;
}
<div>
<div id="first">
<div> First box </div>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters,as opposed to using ''Content here,content here'',making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text,and a search for ''lorem ipsum'' will uncover many web sites still in their infancy. Various
versions have evolved over the years,sometimes by accident,sometimes on purpose (injected humour and the like).
</div>
<div id="second">
<div> Second box</div>
Contrary to popular belief,Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC,making it over 2000 years old. Richard McClintock,a Latin professor at Hampden-Sydney College in Virginia,looked up
one of the more obscure Latin words,consectetur,from a Lorem Ipsum passage,and going through the cites of the word in classical literature,discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum
et Malorum" (The Extremes of Good and Evil) by Cicero,written in 45 BC. This book is a treatise on the theory of ethics,very popular during the Renaissance. The first line of Lorem Ipsum,"Lorem ipsum dolor sit amet..",comes from a line in section
1.10.32.
</div>
</div>
我的解决方案是使用 flex。
而且此解决方案是响应式移动设备,无需使用媒体查询。运行代码段并调整浏览器窗口的大小。块将适应窗口的大小。
此外,切勿多次使用 id
属性。 id
是一个独特的属性。对许多元素使用 class
。
并且始终将您的内容包装在 main 父元素中。
.main {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
p {
width: 40px;
height: 80px;
background-color: Orange;
font-size: large;
float: right;
border: 1px solid black;
}
.headers {
background: Orange;
float: right;
border: 1px solid black;
padding: 3px;
}
#first,#second {
background: LightBlue;
border: 1px solid black;
padding: 10px;
flex: 300px;
}
<div>
<div id="first">
<div> First box </div>
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters,and a search for ''lorem ipsum'' will uncover many web sites still in their infancy. Various versions
have evolved over the years,comes from a line in section
1.10.32.
</div>
</div>