Html 需要CSS wiz的帮助-创建一个表;“看”;不用桌子
我正在尝试创建一个类似以下内容的页面:Html 需要CSS wiz的帮助-创建一个表;“看”;不用桌子,html,css,list,css-tables,Html,Css,List,Css Tables,我正在尝试创建一个类似以下内容的页面: <div id="latestArticlesWrapper"> <div class = "newArticle"> <div class = "newArticleImage"> </div> <div class="newArticleData"> </div>
<div id="latestArticlesWrapper">
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
</div>
(我指的是“了解更多关于我们特色程序的信息:”带有交替颜色的表格)
我宁愿避免使用表,因为据我所知,使用“纯”css更明智
唉,我觉得我的CSS技能有些欠缺
有没有人可以帮助我在CSS中创建这种外观
我的HTML“结构”如下所示:
<div id="latestArticlesWrapper">
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
<div class = "newArticle">
<div class = "newArticleImage">
</div>
<div class="newArticleData">
</div>
</div>
</div>
所以。。。。我怎样才能让你快乐-P
到目前为止,html部分是正确的。您只需要添加一些float元素:
div.latestArticlesWrapper
{
width: #px; /* static width */
}
div.newArticle, div.newArticleAlt
{
float: left;
width: #px; /* should be the width of the entire area to force the float to wrap */
}
div.newArticle
{
background-color: #ffffff;
}
div.newArticleAlt
{
background-color: #eeeeee;
/* alternate row color, use conditional to separate */
}
div.newArticleImage
{
float: left;
width: #px;
padding: #px; /* width + padding = total width */
}
div.newArticleData
{
float: left;
width: #px;
/* don't put padding here for text. use the <p> tag or another <div> */
}
div.latestArticlesWrapper
{
宽度:#px;/*静态宽度*/
}
div.newArticle,div.newArticleAlt
{
浮动:左;
宽度:#px;/*应为迫使浮子缠绕的整个区域的宽度*/
}
新物品组
{
背景色:#ffffff;
}
新文章分类
{
背景色:#eeeeee;
/*交替行颜色,使用条件分隔*/
}
div.newarticle图像
{
浮动:左;
宽度:#px;
填充:#px;/*宽度+填充=总宽度*/
}
div.newArticleData
{
浮动:左;
宽度:#px;
/*不要在此处为文本添加空格。请使用标记或其他标记*/
}
因为您需要一个类似于引用的站点(这是一个静态宽度),所以我在这里为静态宽度添加了样式。如果您有一个动态宽度站点,那么您必须以不同的方式处理宽度。到目前为止,您的html部分是正确的。您只需要添加一些float元素:
div.latestArticlesWrapper
{
width: #px; /* static width */
}
div.newArticle, div.newArticleAlt
{
float: left;
width: #px; /* should be the width of the entire area to force the float to wrap */
}
div.newArticle
{
background-color: #ffffff;
}
div.newArticleAlt
{
background-color: #eeeeee;
/* alternate row color, use conditional to separate */
}
div.newArticleImage
{
float: left;
width: #px;
padding: #px; /* width + padding = total width */
}
div.newArticleData
{
float: left;
width: #px;
/* don't put padding here for text. use the <p> tag or another <div> */
}
div.latestArticlesWrapper
{
宽度:#px;/*静态宽度*/
}
div.newArticle,div.newArticleAlt
{
浮动:左;
宽度:#px;/*应为迫使浮子缠绕的整个区域的宽度*/
}
新物品组
{
背景色:#ffffff;
}
新文章分类
{
背景色:#eeeeee;
/*交替行颜色,使用条件分隔*/
}
div.newarticle图像
{
浮动:左;
宽度:#px;
填充:#px;/*宽度+填充=总宽度*/
}
div.newArticleData
{
浮动:左;
宽度:#px;
/*不要在此处为文本添加空格。请使用标记或其他标记*/
}
因为您需要一个类似于引用的站点(这是一个静态宽度),所以我在这里为静态宽度添加了样式。如果您有一个动态宽度站点,则必须以不同的方式使用宽度。这里是我的尝试:
html
<div id="latestArticlesWrapper">
<div class = "newArticle yellow">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
<div class = "newArticle white">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
<div class = "newArticle yellow">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
<div class = "newArticle white">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
<div class = "newArticle yellow">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
</div>
要更改行的颜色,只需更改newArticle
class附近的类即可
PS:以表格数据为例,我建议您使用表格,它更具语义,然后您可以通过css设置样式。但是如果您仍然想使用div,那么可以按照上面的解决方案进行操作。这里是我的尝试:
html
<div id="latestArticlesWrapper">
<div class = "newArticle yellow">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
<div class = "newArticle white">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
<div class = "newArticle yellow">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
<div class = "newArticle white">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
<div class = "newArticle yellow">
<div class = "newArticleImage"><img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" />
</div>
<div class="newArticleData"><h3>Rhinoplasty (Nose Job)</h3>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.
</div>
</div>
</div>
要更改行的颜色,只需更改newArticle
class附近的类即可
PS:以表格数据为例,我建议您使用表格,它更具语义,然后您可以通过css设置样式。但是如果您仍然想使用div,那么您可以按照上面的解决方案进行操作。将其保存到文件并在浏览器中打开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Latest Articles Example</title>
<style>
#latestArticlesWrapper { font-family:arial,sans-serif; width:560px; }
#latestArticlesWrapper .odd { background-color:#F2E4C2; }
#latestArticlesWrapper .even { background-color:#FFFFFF; }
.newArticleImage { text-align:center; margin:10px 0 10px 0; float:left; display:inline; width:140px; }
.newArticleData { float:left; display:inline; width:410px; padding:0 10px 0 0;}
.newArticleData h4 { font-size:14px; margin:10px 0 0 0;}
.newArticleData p { font-size:0.8125em; margin:5px 0 0 0; line-height:1.5em; }
</style>
<!-- The following styles are from http://www.positioniseverything.net/easyclearing.html -->
<style type="text/css">
.clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.clearfix {display: inline-block;} /* for IE/Mac */
</style>
<!--[if IE]>
<style type="text/css">
.clearfix { zoom: 1; display: block; }
</style>
<![endif]-->
</head>
<body>
<div id="latestArticlesWrapper">
<div class="newArticle odd clearfix">
<div class="newArticleImage">
<img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" alt="">
</div>
<div class="newArticleData">
<h4>Rhinoplasty (Nose Job)</h4>
<p>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.</p>
</div>
</div>
<div class="newArticle even clearfix">
<div class="newArticleImage">
<img src="http://www.drmichaelbogdan.com/images/featured-breast-augmentation.jpg" alt="">
</div>
<div class="newArticleData">
<h4>Breast Enlargement</h4>
<p>With more choices than ever before, breast augmentation is an excellent option for women who are unsatisfied with the size of their breasts, and would like to create a more voluptuous silhouette.</p>
</div>
</div>
<div class="newArticle odd clearfix">
<div class="newArticleImage">
<img src="http://www.drmichaelbogdan.com/images/featured-mommy-makeover.jpg" alt="">
</div>
<div class="newArticleData">
<h4>Mommy Makeover</h4>
<p>After having children, many mothers desire a Mommy Makeover to regain their pre-baby body. A Mommy Makeover can return a youthful appearance to your breasts and tummy.</p>
</div>
</div>
</div>
</body>
</html>
最新文章示例
#latestArticlesWrapper{字体系列:arial,无衬线;宽度:560px;}
#latestArticlesWrapper.odd{背景色:#F2E4C2;}
#latestArticlesWrapper.偶数{背景色:#FFFFFF;}
.newarticle图像{文本对齐:居中;边距:10px 0 10px 0;浮点:左;显示:内联;宽度:140px;}
.newArticleData{float:left;display:inline;width:410px;padding:010px 0;}
.newArticleData h4{字体大小:14px;边距:10px 0;}
.newArticleData p{字体大小:0.8125em;边距:5px 0 0;行高:1.5em;}
.clearfix:在{content:“.”之后显示:块;高度:0;清除:两者;可见性:隐藏;}
.clearfix{display:inline block;}/*用于IE/Mac*/
鼻整形术(鼻整形术)
鼻子形状或大小的细微变化会对整体面部外观产生巨大影响。鼻整形术,也称为整容鼻手术,可以帮助人们对自己的外表更加自信
乳房增大
对于那些对自己乳房的大小不满意,并且想要创造一个更性感的轮廓的女性来说,隆胸是一个极好的选择
妈咪化妆
有了孩子后,许多母亲都希望妈妈能改头换面,以恢复她们在孩子出生前的身体。妈妈的化妆可以让你的胸部和腹部恢复青春
看来我来晚了 将此保存到文件并在浏览器中打开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Latest Articles Example</title>
<style>
#latestArticlesWrapper { font-family:arial,sans-serif; width:560px; }
#latestArticlesWrapper .odd { background-color:#F2E4C2; }
#latestArticlesWrapper .even { background-color:#FFFFFF; }
.newArticleImage { text-align:center; margin:10px 0 10px 0; float:left; display:inline; width:140px; }
.newArticleData { float:left; display:inline; width:410px; padding:0 10px 0 0;}
.newArticleData h4 { font-size:14px; margin:10px 0 0 0;}
.newArticleData p { font-size:0.8125em; margin:5px 0 0 0; line-height:1.5em; }
</style>
<!-- The following styles are from http://www.positioniseverything.net/easyclearing.html -->
<style type="text/css">
.clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.clearfix {display: inline-block;} /* for IE/Mac */
</style>
<!--[if IE]>
<style type="text/css">
.clearfix { zoom: 1; display: block; }
</style>
<![endif]-->
</head>
<body>
<div id="latestArticlesWrapper">
<div class="newArticle odd clearfix">
<div class="newArticleImage">
<img src="http://www.drmichaelbogdan.com/images/featured-rhinoplasty.jpg" alt="">
</div>
<div class="newArticleData">
<h4>Rhinoplasty (Nose Job)</h4>
<p>Subtle changes in the shape or size of the nose can have a tremendous impact on overall facial appearance. Rhinoplasty, also known as cosmetic nose surgery, can help people feel more confident about their appearance.</p>
</div>
</div>
<div class="newArticle even clearfix">
<div class="newArticleImage">
<img src="http://www.drmichaelbogdan.com/images/featured-breast-augmentation.jpg" alt="">
</div>
<div class="newArticleData">
<h4>Breast Enlargement</h4>
<p>With more choices than ever before, breast augmentation is an excellent option for women who are unsatisfied with the size of their breasts, and would like to create a more voluptuous silhouette.</p>
</div>
</div>
<div class="newArticle odd clearfix">
<div class="newArticleImage">
<img src="http://www.drmichaelbogdan.com/images/featured-mommy-makeover.jpg" alt="">
</div>
<div class="newArticleData">
<h4>Mommy Makeover</h4>
<p>After having children, many mothers desire a Mommy Makeover to regain their pre-baby body. A Mommy Makeover can return a youthful appearance to your breasts and tummy.</p>
</div>
</div>
</div>
</body>
</html>
最新文章示例
#latestArticlesWrapper{字体系列:arial,无衬线;宽度:560px;}
#latestArticlesWrapper.odd{背景色:#F2E4C2;}
#latestArticlesWrapper.偶数{背景色:#FFFFFF;}
.newarticle图像{文本对齐:居中;边距:10px 0 10px 0;浮点:左;显示:内联;宽度:140px;}
.newArticleData{float:left;display:inline;width:410px;padding:010px 0;}
.newArticleData h4{字体大小:14px;边距:10px 0;}
.newArticleData p{字体大小:0.8125em;边距:5px 0 0;行高:1.5em;}
.clearfix:在{content:“.”之后显示:块;高度:0;清除:两者;可见性:隐藏;}
.clearfix{display:inline block;}/*用于IE/Mac*/
鼻整形术(鼻整形术)
鼻子形状或大小的细微变化会对整体面部外观产生巨大影响。犀牛
dt, dd {
position: relative;
padding: 0 0 0 110px;
}
dd img {
position: absolute;
top: -1em;
left: 0.2em;
}
dt {
font-weight: bold;
}
dd {
margin: 0 0 1em 0;
}