GVKun编程网logo

html – 将div对齐到右边,防止容器崩溃(html中让div内容靠左对齐)

20

以上就是给各位分享html–将div对齐到右边,防止容器崩溃,其中也会对html中让div内容靠左对齐进行解释,同时本文还将给你拓展css–如何使主div容器对齐到中心、css–将div对齐到其容器的

以上就是给各位分享html – 将div对齐到右边,防止容器崩溃,其中也会对html中让div内容靠左对齐进行解释,同时本文还将给你拓展css – 如何使主div容器对齐到中心、css – 将div对齐到其容器的底部、DIV容器内的HTML图像底部对齐、html – Bootstrap – 将DIV对齐到顶部,中间和底部等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

html – 将div对齐到右边,防止容器崩溃(html中让div内容靠左对齐)

html – 将div对齐到右边,防止容器崩溃(html中让div内容靠左对齐)

我无法尝试将事件信息类文本作为垂直列表与事件日历的右侧对齐.将事件列表向右浮动似乎完全崩溃了我的文本,这是我不想要的.这是我的HTML和CSS:

.workshop-events {
  width: 100%;
  background-color: #f2f2f2;
  padding: 1px 20px;
  /*padding: 20px;*/
}
.calendar {
  width: 75px;
  display: table-cell;
}
.calendar .month {
  text-transform: uppercase;
  font-size: 16px;
  border: 1px solid #b2b2b2;
  padding: 3px 0;
  background: #FFF;
}
.calendar .day {
  font-size: 30px;
  font-weight: 500;
  border: 1px solid #b2b2b2;
  border-top: none;
  padding: 7px 0;
  background: #FFF;
}
.calendar .day {
  font-size: 30px;
  font-weight: 500;
  border: 1px solid #b2b2b2;
  border-top: none;
  padding: 7px 0;
  background: #FFF;
}
.events-info {
  font-weight: bold;
  font-size: 14px;
}
heading">WORKSHOP & EVENTS
最佳答案
您只需将日历框浮动到左侧即可.为了获得更好的结果,将所有events-info按钮包装到一个容器中(以避免文本换行到日历框下面的新行,请参阅演示).

HTML更新:

CSS更新:

.workshop-events {
  overflow: auto; /*fix possible collapses caused by floating*/
}
.calendar {
  float: left;
  margin-right: 20px;
}
.events-container {
  overflow: auto; /*prevent the text to wrap below the calendar*/
}
.workshop-events {
  width: 100%;
  background-color: #f2f2f2;
  padding: 20px;
}
.calendar {
  width: 75px;
  display: table-cell;
}
.calendar .month {
  text-transform: uppercase;
  font-size: 16px;
  border: 1px solid #b2b2b2;
  padding: 3px 0;
  background: #FFF;
}
.calendar .day {
  font-size: 30px;
  font-weight: 500;
  border: 1px solid #b2b2b2;
  border-top: none;
  padding: 7px 0;
  background: #FFF;
}
.calendar .day {
  font-size: 30px;
  font-weight: 500;
  border: 1px solid #b2b2b2;
  border-top: none;
  padding: 7px 0;
  background: #FFF;
}
.events-info {
  font-weight: bold;
  font-size: 14px;
}

/*NEW RULES BELOW*/
.workshop-events {
  overflow: auto;
}
.calendar {
  float: left;
  margin-right: 20px;
}
.events-container {
  overflow: auto;
}
heading">WORKSHOP & EVENTS

css – 如何使主div容器对齐到中心

css – 如何使主div容器对齐到中心

大家好,

我一直在想知道其他人如何与主要的集装箱中心对齐,因为我迄今为止管理的唯一方法是将以下内容添加到css文件中:@H_301_3@

* {
填充:自动;
保证金:汽车;
文本对齐:中心;
}@H_301_3@

我看到其他页面使用:
* {填充:0像素;边缘:0像素}
但是我不能看到他们在做什么或做什么来集中主容器.@H_301_3@

有人可以解释一下吗@H_301_3@

代码示例:@H_301_3@

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<Meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
<title>This is the main container</title>
<style type="text/css">
*{
padding:auto;
margin:auto;
text-align:center;
}
</style>
</head>
<body>
<divhttps://www.jb51.cc/tag/dis/" target="_blank">display:block;height:400px;">
<b>This is the main container.</b>
</div>
</body>
</html>

任何人都可以在下面的页面中解释他们如何做?
http://www.csszengarden.com/?cssfile=/179/179.css&page=4@H_301_3@

谢谢@H_301_3@

解决方法

不要使用*选择器,因为这将适用于页面上的所有元素.假设你有一个这样的结构:
...
<body>
    <div id="content">
        <b>This is the main container.</b>
    </div>
</body>
</html>

然后,您可以使用以下方式居中#content div:@H_301_3@

#content {
    width: 400px;
    margin: 0 auto;
    background-color: #66ffff;
}

不知道你在别处见过什么,但这是要走的路. * {margin:0;填充:0;你看过的代码片段是为所有浏览器重置浏览器的默认定义,使您的网站在所有浏览器上的行为类似,这与集中主体无关.@H_301_3@

大多数浏览器对某些通常与其他浏览器的实现不一致的元素应用默认边距和填充.这就是为什么通常被认为是聪明的使用这种“重置”.您提供的重置代码片段是最简单的重置样式表,您可以在此处阅读更多关于主题的内容:@H_301_3@

> http://meyerweb.com/eric/tools/css/reset/@H_301_3@

css – 将div对齐到其容器的底部

css – 将div对齐到其容器的底部

我认为这很简单,我需要将两个内部的div(绿色和蓝色)对齐到容器的底部(红色)。我希望不要使用绝对定位,我需要它是ie6,7,8 ff chrome safari等兼容。
<div>
    <div></div>
    <div></div>
    <div></div>
</div>

我已经尝试使用vertical-align,但找不到一个简单的解决方案。

感谢帮助,p。

编辑这里是我尝试abs pos解决方案:

<div>
    <divhttps://www.jb51.cc/tag/ott/" target="_blank">ottom:0px;"></div>
    <divhttps://www.jb51.cc/tag/ott/" target="_blank">ottom:0px;"></div>
    <div></div>
</div>

解决方法

为什么不能使用绝对定位? Vertical-align不起作用(表除外)。使你的容器的位置:亲戚。然后使用底部绝对定位内部div:0;应该像一个魅力一样工作。

编辑zoidberg(我会更新答案)

<div>
   <divhttps://www.jb51.cc/tag/ott/" target="_blank">ottom: 0; left: 0; width: 20px; height: 20px;"></div>
   <divhttps://www.jb51.cc/tag/ott/" target="_blank">ottom: 0; left: 20px; width: 20px height: 20px;"></div>
</div>

DIV容器内的HTML图像底部对齐

DIV容器内的HTML图像底部对齐

我有一个具有固定高度的div标签。大多数图像具有相同的高度和宽度。

我想将图像对齐在div的底部,以便它们被很好的排列。这是我到目前为止

<div id="randomContainer">
    <div id="imageContainer">
        <img src="1.png" alt=""/>
        <img src="2.png" alt=""/>
        <img src="3.png" alt=""/>
        <img src="4.png" alt=""/>
    </div>
    <div id="navigationContainer">
        <!-- navigation stuff -->
    </div>
</div>

CSS看起来像:

div#imageContainer {
    height: 160px;  
    vertical-align: bottom;
    display: table-cell;
}

我设法使底部的图像与display:table-cell和vertical-align:bottom css属性对齐。

有没有更清晰的方法来显示div作为表格单元格并对齐DIV标签底部的图像?

解决方法

这是你的代码: http://jsfiddle.net/WSFnX/

使用display:table-cell是很好的,只要你知道它不会在IE6 / 7中运行。除此之外,它是安全的:Is there a disadvantage of using `display:table-cell`on divs?

要固定底部的空间,请将vertical-align:bottom添加到实际的imgs中:

http://jsfiddle.net/WSFnX/1/

删除图像之间的空间可以归结为:bikeshedding CSS3 property alternative?

所以,这是一个演示,HTML中的空格被删除:http://jsfiddle.net/WSFnX/4/

html – Bootstrap – 将DIV对齐到顶部,中间和底部

html – Bootstrap – 将DIV对齐到顶部,中间和底部

我需要在容器DIV中有三个DIV,所有DIV都水平居中.第一个需要与容器的垂直顶部对齐,第二个与垂直中心对齐,第三个与垂直底部对齐.这是 an answer垂直定位div,但不解决其他项目.另一个答案 here,但是你如何添加需要垂直对齐顶部和底部的DIV?

这是HTML:

<div> <!-- outer container; all items horizontally centered -->
    <div> <!-- align this DIV to top -->
        <h1>Top DIV</h1>
    </div>
    <div> <!-- align this DIV to center -->
        <div>Middle DIV</div>
    </div>
    <divhttps://www.jb51.cc/tag/ott/" target="_blank">ottom">
        <divhttps://www.jb51.cc/tag/ott/" target="_blank">ottom">Bottom DIV</div>
    </div>
</div>

解决方法

对于这个HTML:

<div>
  <div> <!-- outer container; all items horizontally centered -->
    <div> <!-- align this DIV to top -->
        <div>Top DIV</div>
    </div>
    <div> <!-- align this DIV to center -->
        <div>Middle DIV</div>
    </div>
    <divhttps://www.jb51.cc/tag/ott/" target="_blank">ottom">
        <divhttps://www.jb51.cc/tag/ott/" target="_blank">ottom">Bottom DIV</div>
    </div>
  </div>
</div>

这个CSS:

.carousel-caption{
    padding:0;
 }

.vtop{
  /*padding on parent fixes this*/
}

.vcenter{
    position: relative;
    top: 50%;
    transform: translateY(-50%); 
}

.vbottom{
    position: relative;
    top: 100%;
    transform: translateY(-100%); 
}

this Bootply Demo

HTH!

今天关于html – 将div对齐到右边,防止容器崩溃html中让div内容靠左对齐的介绍到此结束,谢谢您的阅读,有关css – 如何使主div容器对齐到中心、css – 将div对齐到其容器的底部、DIV容器内的HTML图像底部对齐、html – Bootstrap – 将DIV对齐到顶部,中间和底部等更多相关知识的信息可以在本站进行查询。

本文标签:

上一篇如何将HTML表单输入存储为JavaScript对象(html怎么保存输入的表单)

下一篇html – 表行边框 – 半输入,半输出(html表格边框void)