几个经典的css技巧
使用 line-height 垂直居中
line-height:24px;
使用固定宽度的容器并且需要一行垂直居中时,使用 line-height 即可(高度与父层容器一致),更多的垂直居中总结可以看这里。
清除容器浮动
#main {
overflow:hidden;
}
不让链接折行
a {
white-space:nowrap;
}
上面的设定就能避免链接折行,不过个人建议长链接会有相应的这行(有关换行方面的讨论,参看圆心的记录)。
始终让 Firefox 显示滚动条
html {
overflow:-moz-scrollbars-vertical;
}
更多的 Mozilla/Firefox 私有 CSS 属性可以参考这里。需跨浏览器的支持,也可以使用。
body, html {
min-height:101%;
}
使块元素水平居中
margin:0 auto;
其实就是:
margin-left: auto;
margin-right: auto;
这个技巧基本上所有的 CSS 教科书都会有说明,别忘记给它加上个宽度。Exploer 下也可以使用。
body{
text-align: center;
}
然后定义内层容器。
text-align: left;
恢复。
隐藏 Exploer textarea 的滚动条
textarea {
overflow:auto;
}
Exploer 默认情况下 textarea 会有垂直滚动条(不要问我为什么)。
设置打印分页
h2 {
page-break-before:always;
}
page-break-before 属性能设置打印网页时的分页。
删除链接上的虚线框
a:active, a:focus {
outline:none;
}
Firefox 默认会在链接获得焦点(或者点击时)加上条虚线框,使用上面的属性可以删除。
最简单的 CSS 重置
* {
margin: 0; padding: 0
}
相关文档:
CSS 和 JavaScript 标签 style 属性对照表:
盒子标签和属性对照
CSS语法(不区分大小写) JavaScript语法(区分大小写)
border border
border-bottom borderBottom
border-bottom-color borderBottomColor
border-bottom-style borderBottomStyle
border-bottom-width borderBottomWidth
border-color bor ......
-----------------------------------------------
链接外面文件css
<link href="layout.css" rel="stylesheet" type="text/css" />
-----------------------------------------------
写文本 : <div id="mainContent">
<p>1列固定宽度居中+头部+导航+尾部—&mdash ......
jsp页面调用 <link type="text/css" rel="stylesheet" href="css/style.css"/>样式表
其他样式都可以再页面正常显示
.button-qingchu{background:url(images/qingchu.jpg); width:70px; height:30px; border:0px;} 像这样的背景图片样式就显示不出图片是什么问题! Myeclipse 6.5
在html中都可以显示 在jsp中显示 ......
转载于 罗马集市
Magento的CSS文件一般存放到 $MAGENTO_INSTALLED_FOLDER/skin/{frontend | admin |
install}/<package name>/<theme
name>/css目录下。也有些和全局js脚本配合使用的css文件存放在$MAGENTO_INSTALLED_FOLDER/js下,但是一
般我们不直接调用它们。
那么Magento应用又是如何引用CSS文件的呢 ......
最近的面试中总是问我一些浏览器兼容性问题,所以下面做一个总结:
为什么会出现这种现象呢?主要就是像Firefox这样浏览器良好支持W3C标准,是目前对CSS支持最好的浏览器,而ie是出现的比较早,在w3c支持方面做的一直不是很好。有很多东西出现FF和IE显示不一样的根本原因在于它们的默认显示不一样,而这个默认样式该如何显 ......