html绘制图例,以图例⽅式介绍CSS制作⽹页详细步骤
典故成语>三文鱼头汤的做法⾸先要做的是确定页⾯结构。随着你对CSS布局的逐步学习,这个过程会变得越来越简单。通过运⽤⼤量绝对定位和⼤幅背景图⽚,我们可以⾮常简单地完成这个设计。
第九步
上图中,logo和头部元素看上去摆在了正确的位置,但菜单还有点⼉怪怪的。设计样式前我们先说⼀下logo和⼤⽂本图⽚的事。你可能在想,既然它俩都是图⽚为什么不放在背景图⽚⾥就好了?
这是因为我们需要给logo加上链接,点击可返回⾸页(让⽹站更好⽤)。⽽⼤⽂本图⽚可能要随页⾯⽽变,把它做成单独的图⽚我们就可以让⼤量HTML页⾯使⽤同⼀个CSS样式表,只要换上⽂字不同的图⽚就可以了。
现在咱们来设计那两个菜单,让页⾯真正开始成型。要⽤到的CSS如下:
ul#menu {
margin:0px; padding:0px;
position:absolute; top:138px; left:75px;
}
ul#right_menu {
margin:0px; padding:0px;
position:absolute; top:138px; rightright:110px;
我爱过
}
ul#menu li, ul#right_menu li {
margin:0px; padding:0px;
list-style:none;
margin-right:10px;
天猫设计font-size:9px;
text-transform:upperca;
display:inline;
}
ul#menu li a, ul#right_menu li a {
text-decoration:none;
color:#bd92b2;
}
ul#menu li a:hover, ul#right_menu li a:hover {
text-decoration:none;
color:#ffffff;
}
头两条代码和之前⼀样(除了稍微调整了定位让它们仍然正确显⽰)。注意,因为两个菜单的位置不⼀
样,这两条定义是分开的,但菜单选项的样式是相同的,所以我们把后⾯两条定义并成了⼀条。把两个属性⼀起定义的格式是:
.myClass, .myClass2 { ... }
这和下⾯的定义是完全不同的:
.myClass .myClass2 { ... }
因为第⼆个定义声明的对象是位于class="myClass"的标签内的所有class="myClass2"的元素
箱型梁回到我们的样式表,看⼀遍重要的⼏点:
和前⾯⼀样,我们把
元素设为0 margin和0 padding,并绝对定位。
然后我们为
内部所有的
元素做出声明,让它们没有列表样式(即没有圆点),9px⼤⼩,统统⼤写,最重要的,让它们display:inline(译者注:⾏内显⽰)。⾏内显⽰意味着它们排成⼀⾏,⽽不是⼀个接在另⼀个下⾯。
接下来的定义声明了
内部的链接们应该是某个颜⾊的并且没有下划线。这⾥的
包括 和内的所有
。
加上这些定义,我们的页⾯现在看上去相当不错啦!
第⼗步
现在该增加内容了!我们先写些伪⽂本来形成列。下⾯是HTML:
a sleek design
Dummy Text: This design was produced for a photoshop and web development tutorial. You can e the first part up where you learn how to create a beautiful, but simple design using an abstract background and type.
The cond part of the tutorial is available where we do a quick build of the PSD into a viable, working HTML/CSS site.
This design was produced for a photoshop and web development tutorial. You can e the first part up where you learn how to create a beautiful, but simple design using an abstract background and type.
The cond part of the tutorial is available where we do a quick build of the PSD into a viable, working HTML/CSS site.
tutorials
Dummy Text: This design was produced for a photoshop and web development tutorial. You can e the first part up where you learn how to create a beautiful, but simple design using an abstract background and type.
The cond part of the tutorial is available where we do a quick build of the PSD into a viable, working HTML/CSS site.
This design was produced for a photoshop and web development tutorial. You can e the first part up where you learn how to create a beautiful, but simple design using an abstract background and type.
The cond part of the tutorial is available where we do a quick build of the PSD into a viable, working HTML/CSS site.
recent work
Dummy Text: This design was produced for a photoshop and web development tutorial. You can e the first part up where you learn how to create a beautiful, but simple design using an abstract background and type.
The cond part of the tutorial is available where we do a quick build of the PSD into a viable, working HTML/CSS site.
This design was produced for a photoshop and web development tutorial. You can e the first part
up where you learn how to create a beautiful, but simple design using an abstract background and type.
The cond part of the tutorial is available where we do a quick build of the PSD into a viable, working HTML/CSS site.
在这段代码中,你可以看到我在内容区域加了3个新的
,每⼀个
包含⼀个
标题元素和⼀些⽂本。他们的class名称是column1、column2、column3(列1、列2、列3)。加上⽂本是为了展⽰怎样形成列。
为了让他们看上去像列的样⼦我们先来添加⼀段CSS:
/*
好看边框Content
*/
#content {
padding-top:435px;
padding-left:85px;
width:815px;
青春作伴好还乡的上一句color:#674f5d;
font-size:13px;
line-height:20px;
}
.column1 { float:left; width:230px; margin-right:30px; }
.column2 { float:left; width:230px; margin-right:30px; }
.
column3 { float:left; width:270px; }
我⽤⼀句注释为新的CSS段落起头,然后为#content设置样式。注意padding-top值....435px!设这么⼤是为了给之前绝对定位的元素空出地⽅。与绝对定位的元素不同,content是从属于页⾯正常流的。
这是因为你还要在content中加⼊更多内容,把footer推到下⾯去。绝对定位会让它覆盖在footer上⽅。
然后我给三个column分别设置宽度并加上float:left,这可以让它们漂向页⾯左边,与其他向左浮动的元素对齐。为了不让他们紧挨在⼀起,我给前两个column赋予了右外边距。
浮动⼀个元素会让它漂到左侧或右侧,并使其它元素环绕在其四周。加⼊另⼀个浮动元素,⼆者会并排成列。基本上你看到的列布局都运⽤了float(浮动)。
不幸的是,浮动元素会出现⼀个怪问题——它们跟⾃⼰的容器不对付,并且会漂到下⼀个元素上⽅⽽不是把它往下推。解决这个问题的⽅法就是给浮动元素后⾯的某个元素加上属性clear:both。
Clear(清理)属性可以阻⽌元素环绕浮动的
,这有点⼉不好解释,我们直接看看清理和不清理分别会出现什么状况吧。赞美大自然的诗句