用css给不定高的<div class=“tips”><div>垂直居中,请写出三种方法。

html-css04

用css给不定高的<div class=“tips”><div>垂直居中,请写出三种方法。,第1张

1.定位top50% margin-top:-50% 2.给父级设置高和行高相等,3.用一个“ghost”伪元素(看不见的伪元素)和 inline-block / vertical-align 可以搞定居中,非常巧妙。但是这个方法要求待居中的元素是 inline-block,不是一个真正通用的方案。

你给第二个#top_tel加个float:left然后top的总宽度要大于430+261+368+132+20,不设宽度也行跟高度没关系 margin:0px 0px 0px 0px 可以缩写为margin:0px一样的话没必要去每个都写,还有,你既然#top_tel{width:261pxheight:69pxmargin:15px 0px 0px 430pxbackground:url(images/TEL.jpg) no-repeat}

要左边距430px为什么不把这个做成这样的,这两个都右漂浮不是更好

<div id="top_tips">565656</div>

<div id="top_tel"></div>

小小的给你改下

#top{ background:url(images/topbj.gif) repeat-x #000000height:92px}

#top_logo{width:368pxheight:52pxfloat:leftpadding:20px 0px 0px 20px}

#top_tel{width:261pxheight:69pxmargin-top:15pxbackground:url(images/TEL.jpg) no-repeatfloat:right}

#top_tips{background:url(images/tips.gif) no-repeat top leftwidth:132pxheight:18pxfloat:rightmargin:0px}

网页代码:

<div id="top">

<div id="top_logo"><a href="#"><img src="images/logo.jpg" border="0" alt="网站LOGO" /></a></div>

<div id="top_tips">565656</div>

<div id="top_tel"></div>

</div><!--头部结束-->

1.基本命名

头:header

内容:content/container

尾:footer

导航:nav

侧栏:sidebar

栏目:column

页面外围控制整体布局宽度:wrapper

左右中:left right center

登录条:loginbar

标志:logo

广告:banner

页面主体:main

热点:hot

新闻:news

下载:download

子导航:subnav

菜单:menu

子菜单:submenu

搜索:search

友情链接:friendlink

页脚:footer

版权:copyright

滚动:scroll

内容:content

标签页:tab

文章列表:list

提示信息:msg

小技巧:tips

栏目标题:title

加入:joinus

指南:guild

服务:service

注册:regsiter

状态态:status

投票:vote

合作伙伴:partner

注释的写法

/* Footer */

内容区

/* End Footer */

id的命名

容器: container

页头:header

内容:content/container

页面主体:main

页尾:footer

导航:nav

侧栏:sidebar

栏目:column

页面外围控制整体布局宽度:wrapper

左右中:left right center

id的命名

页面结构

容器: container

页头:header

内容:content/container

页面主体:main

页尾:footer

导航:nav

侧栏:sidebar

栏目:column

页面外围控制整体布局宽度:wrapper

左右中:left right center

导航

导航:nav

主导航:mainbav

子导航:subnav

顶导航:topnav

边导航:sidebar

左导航:leftsidebar

右导航:rightsidebar

菜单:menu

子菜单:submenu

标题: title

摘要: summary

功能

标志:logo

广告:banner

登陆:login

登录条:loginbar

注册:regsiter

搜索:search

功能区:shop

标题:title

加入:joinus

状态:status

按钮:btn

滚动:scroll

标签页:tab

文章列表:list

提示信息:msg

当前的: current

小技巧:tips

图标: icon

注释:note

指南:guild

服务:service

热点:hot

新闻:news

下载:download

投票:vote

合作伙伴:partner

友情链接:link

版权:copyright

2.class的命名

(1)颜色:使用颜色的名称或者16进制代码,如

.red { color: red}

.f60 { color: #f60}

.ff8600 { color: #ff8600}

(2)字体大小,直接使用"font+字体大小"作为名称,如

.font12px { font-size: 12px}

.font9pt {font-size: 9pt}

(3)对齐样式,使用对齐目标的英文名称,如

.left { float:left}

.bottom { float:bottom}

(4)标题栏样式,使用"类别+功能"的方式命名,如

.barnews { }

.barproduct { }

3.注意事项

1.一律小写

2.尽量用英文

3.不加中杠和下划线

4.尽量不缩写,除非一看就明白的单词.

主要的 master.css

模块 module.css

基本共用 base.css

布局,版面 layout.css

主题 themes.css

专栏 columns.css

文字 font.css

表单 forms.css

补丁 mend.css

打印 print.css