使用 line-height 垂直居中
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=line-height%3A24px%3B" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
line-height:24px;
line-height:24px;
使用固定宽度的容器并且需要一行垂直居中时,使用 line-height 即可(高度与父层容器一致),更多的垂直居中总结可以看这里。
清除容器浮动
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=%23main%20%7B%0A%20%20%20%20overflow%3Ahidden%3B%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
#main {
-
overflow:hidden;
-
}
#main {
overflow:hidden;
}
期前也提到过这样的问题,更多信息可以看这里。
不让链接折行
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=a%20%7B%0A%20%20%20%20white-space%3Anowrap%3B%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
a {
-
white-space:nowrap;
-
}
a {
white-space:nowrap;
}
上面的设定就能避免链接折行,不过个人建议长链接会有相应的这行(有关换行方面的讨论,参看圆心的记录)。
始终让 Firefox 显示滚动条
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=html%20%7B%0A%20%20%20%20overflow%3A-moz-scrollbars-vertical%3B%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
html {
-
overflow:-moz-scrollbars-vertical;
-
}
html {
overflow:-moz-scrollbars-vertical;
}
更多的 Mozilla/Firefox 私有 CSS 属性可以参考这里。需跨浏览器的支持,也可以使用
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=body%2C%20html%20%7B%0A%20%20%20%20min-height%3A101%25%3B%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
body, html {
-
min-height:101
%;
-
}
body, html {
min-height:101%;
}
使块元素水平居中
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=margin%3A0%20auto%3B" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
margin:
0
auto;
margin:0 auto;
其实就是
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=margin-left%3A%20auto%3B%0Amargin-right%3A%20auto%3B" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
margin-left: auto;
-
margin-right: auto;
margin-left: auto;
margin-right: auto;
这个技巧基本上所有的 CSS 教科书都会有说明,别忘记给它加上个宽度。Exploer 下也可以使用
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=body%7B%0A%20%20%20%20text-align%3A%20center%3B%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
body{
-
text-align: center;
-
}
body{
text-align: center;
}
然后定义内层容器
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=text-align%3A%20left%3B" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
text-align: left;
text-align: left;
恢复。
隐藏 Exploer textarea 的滚动条
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=textarea%20%7B%0A%20%20%20%20overflow%3Aauto%3B%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
textarea {
-
overflow:auto;
-
}
textarea {
overflow:auto;
}
Exploer 默认情况下 textarea 会有垂直滚动条(不要问我为什么)。
设置打印分页
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=h2%20%7B%0A%20%20%20%20page-break-before%3Aalways%3B%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
h2 {
-
page-break-before:always;
-
}
h2 {
page-break-before:always;
}
page-break-before 属性能设置打印网页时的分页。
删除链接上的虚线框
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=a%3Aactive%2C%20a%3Afocus%20%7B%0A%20%20%20%20outline%3Anone%3B%0A%7D" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
a:active, a:focus {
-
outline:none;
-
}
a:active, a:focus {
outline:none;
}
Firefox 默认会在链接获得焦点(或者点击时)加上条虚线框,使用上面的属性可以删除。
最简单的 CSS 重置
Css代码 <embed type="application/x-shockwave-flash" width="14" height="15" src="http://www.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" flashvars="clipboard=*%20%7B%0A%20%20%20margin%3A%200%3B%20padding%3A%200%0A%7D%0A" quality="high" allowscriptaccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
-
* {
-
margin: 0
; padding:
0
-
}
分享到:
相关推荐
CSS几个技巧及问题处理,让你看看这些经验之谈.
要说学习CSS3的确很简单,但要精通并掌握那可不容易,现在分享给大家几个常用的CSS属性给人以不同的效果。因为在尝试的过程中始终会出一点小差错。所以那些美丽的CSS站点一定是通过精心调制才得来的。真是在此过程中...
Web开发人员常用需要的CSS开发技巧,值得学习。
对于CSS,可能很多前端开发人员已经驾轻就熟了,有些人也许还在初学阶段,不管怎样,这几个炫酷的CSS技巧你都不容错过,对于大家开发前端很有帮助的。
有些经典的CSS技巧,我们还是需要记住的,这样可以节省我们大量的时间,下面零度就为大家推荐几个比较好的CSS技巧: 1、在不同页面上使用同样的导航代码 许多网页上都有导航菜单,当进入某页时,菜单上相应这一项就...
在制作网页中,我们经常需要用到下面的css,有朋友整理好的特给大家,大家可以看看,一定要记住
这几则CSS技巧都是从网络收集来的,作为老手就当作温故而知新,本文主要面对CSS新手朋友,有一些东西或许不是搞的很明白。而这十则CSS技巧能促进你的学习与编码技巧,更多的知识浏览CSS教程频道内容。希望大家能认真...
想写出好看的网页那么div+css是一定要会的,这是div+css的几个网页布局实例,希望对大家有点帮助!
以下是50个新的CSS技巧,技术和指导,帮助您提高您的下一个网页设计。 1. Security and Performance While CSS is often thought of as merely a styling language, there are ways you can use it to add security...
3.3.2 一些CSS 的实用技巧 3.3.3 怎样调试CSS 3.4 关于CSS 的学习 第4 章 网页头部元素的详细定义 第41 页 4.1 DOCTYPE 的选择 4.1.1 什么是DOCTYPE 4.1.2 选择什么样的DOCTYPE 4.2 名字空间 4.3 编码问题 4.4 meta ...
为了实现这些效果,我们需要借助CSS的其他方法来实现,比如说CSS伪元素,他可以帮助我们模拟出这些CSS无法实现的效果,在开始了解怎么实现这些效果之前,我们一起来看一些DEMO效果,让我们最初一个概念。 伪元素技巧...
您需要了解CSS Web开发人员需要知道CSS技巧在线查看 :globe_showing_Asia-Australia: 快速开始提供几个快速入门选项: 克隆仓库: ...使用安装docsify: npm install docsify-cli -g (or yarn global add ...包含什么贡献
本文总结了用div css进行网页表单布局的五个小技巧可以帮助你更灵活的控制表单,使页面更加满意。 1、表单文本输入的移动选择: 在文本输入栏中,如果加入了提示,来访者往往要用鼠标选取后删除,再输入有用的...
不仅介绍了Dreamweaver 8、Firework 8等常用软件的使用,更重要的是,结合实际网页制作中可能遇到的问题,提供了解决问题的思路、方法、技巧,即使是初学者也可以轻松掌握DIV+CSS布局方式,制作出精美的网页并搭建...
Prezirezirezi 是一个同 是一个同 power pointpower pointpower pointpower pointpower pointpower pointpower point power point power point一样的演示软件,其高端大气上 档次自不必说度娘谷歌一样的演示软件,其...