2008-10-08 83 views
0

代码和预览:what i have http://img78.imageshack.us/img78/9795/previewec9.gif我怎样才能得到这个div的一部分坐在一起?

<html> 
<head> 
<title>Testing some CSS</title> 
<style type="text/css"> 
.dDay { 
    font-size:205% 
} 
.dMon { 
    font-weight:bold; 
    font-variant:small-caps; 
    font-size:130%; 
    margin-top:-.7em; 
} 
.detailContainer { 
    vertical-align:middle; 
    display:table-cell; 
    padding:0em 0em 0em 1em; 
} 
#dContainer { 
    border:1px solid green; 
    display:table; 
    height:3.25em; 
    } 
</style> 
<body> 
<div id="dContainer"> 
    <div class="dDay">31</div> 
    <div class="dMon">sep</div> 
    <div class="detailContainer">Test O.O</div> 
</div> 
</body> 
</html> 

我的问题是:是否有可能到明年将其他日期部分,第一个,所以才出现这样的:what i want http://img505.imageshack.us/img505/2787/previewsp2.gif


编辑:奇怪,我试图浮动之前我问的问题,并没有工作...感谢大家:d

回答

2
<html> 
<head> 
<title>Testing some CSS</title> 
<style type="text/css"> 
.dDay { 
    font-size:205% 
} 
.dMon { 
    font-weight:bold; 
    font-variant:small-caps; 
    font-size:130%; 
    margin-top:-.7em; 
} 
.detailContainer { 
    vertical-align:middle; 
    display:table-cell; 
    padding:0em 0em 0em 1em; 
} 
#dContainer, #dContainer2 { 
    border:1px solid green; 
    display:table; 
    height:3.25em; 
    float: left; 
    } 
</style> 
<body> 
<div id="dContainer"> 
    <div class="dDay">31</div> 
    <div class="dMon">sep</div> 
</div> 
<div id="dContainer2"> 
    <div class="dDay">31</div> 
    <div class="dMon">sep</div> 
    <div class="detailContainer">Test O.O</div> 
</div> 
</body> 
</html> 
3

使用风格=“浮动:左”每个DIV(直接或通过一个样式表)

+0

我想我将不得不作出额外的div来包含日期和月份,然后浮正确的吗? – Anders 2008-10-08 15:36:22

+0

不会“显示:table-cell;”不通过v7在IE中工作? – matthewdunnam 2008-10-08 18:26:02

1

浮动:左,如果你想将元素阻塞到s它彼此相邻。

0
  1. 复制dContainer和放置副本后,立即它。
  2. 更改ID和新的ID给#dContainer风格。
  3. 加入刚刚#dContainer(不是新的div)新的CSS块,并把“浮动:左;”在块中。
0
<html> 
<head> 
<title>Testing some CSS</title> 
<style type="text/css"> 
.dDay { 
    font-size:205% 
} 
.dMon { 
    font-weight:bold; 
    font-variant:small-caps; 
    font-size:130%; 
    margin-top:-.7em; 
} 
.dDate { 
    display:table-cell; 
} 
.detailContainer { 
    vertical-align:middle; 
    display:table-cell; 
    padding-left:1em; 
} 
#dContainer { 
    border:1px solid green; 
    display:table; 
    height:3.25em; 
} 
</style> 
<body> 
<div id="dContainer"> 
    <div class="dDate"> 
     <div class="dDay">31</div> 
     <div class="dMon">sep</div> 
    </div> 
    <div class="dDate"> 
     <div class="dDay">31</div> 
     <div class="dMon">sep</div> 
    </div> 
    <div class="detailContainer">Test O.O</div> 
</div> 
</body> 
</html> 

[编辑]综观其他答案:
- 浮动当然是正确的答案,我只是与最初的逻辑去的,实际上完成它(做一个真正的表可能是其实逻辑最后一步......)
- 注意:不会好看在IE(6,7)。

0

有什么理由,为什么你不能使用<跨度>标签,而不是<格>的?这样,您的网页在没有CSS的情况下阅读时仍然有意义。

相关问题