一段自适应的CSS代码

一段自适应HTML5的CSS代码,该代码在陕西特产使用过,手机端效果还好,就是PC端看起来没那么大气,比较窄屏
* { transition-property: all; -ms-transition-property: all; -moz-transition-property: all; -webkit-transition-property: all; -o-transition-property: all; } html, body { font-size:14px; background:#fff; width:100%; margin:0px; padding:0px; font-family: "Microsoft YaHei", Helvetica Neue, Tahoma, Arial, "微软雅黑", "宋体", "黑体"; } img { border:0px; } ul, li, p { margin:0px; padding:0px; } a { text-decoration: none; } ul, li { list-style-type:none; } input, button, select, textarea, select, option { outline:none; } select, option, textarea { resize:none; -webkit-appearance: none; padding:0; margin:0; font-weight:normal; } input[type="button"], input[type="submit"], input[type="reset"], input[type="text"] { -webkit-appearance: none; padding:0; margin:0; font-weight:normal; } .container { position:relative; width:1200px; margin:0px auto; } .container:after { content: "020"; display: block; height: 0; clear: both; visibility:hidden; } .mainTitle { width:295px; margin:0 auto; line-height:70px; color:#666; font-size:40px; text-align:center; border-top:1px solid #d5d5d5; border-bottom:1px solid #d5d5d5; } .seach { position:relative; margin-top:40px; width:300px; height:30px; background:#fff; } .seach .seachText { width:260px; color:#999999; font-size:12px; padding:0 0 0 6px; line-height:1; margin:0; border:0; height:30px; } .seach .btn { cursor:pointer; position:absolute; top:0; right:0; width:30px; height:30px; text-align:center; line-height:30px; background:#474747; } .seach .btn { transition-duration: .5s; -ms-transition-duration: .5s; -moz-transition-duration: .5s; -webkit-transition-duration: .5s; } .seach .btn:hover { background:#000; } .seach .btn img { vertical-align:middle; } .vedioHide { display:none; position:fixed; top:0px; left:0px; width:100%; height:100%; background:url(../images/blackbg.png); z-index:4; } .vedioContent { display:none; position:fixed; top:50%; left:50%; width:650px; height:450px; margin:-260px 0 0 -335px; z-index:5; background:#fff; padding:20px 20px 50px 20px; box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); -moz-box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); -ms-box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); -o-box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); -webkit-box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); border-radius:6px; -moz-border-radius:6px; -ms-border-radius:6px; -o-border-radius:6px; -webkit-border-radius:6px; } .vedioContent iframe { width:100% !important; height:100% !important; } .vedioContent .vedioClose { position:absolute; bottom:18px; right:24px; cursor:pointer; } .header { position:fixed; width:100%; height:120px; background:#fff; z-index:5; border-bottom:1px solid #e0e0e0; } .header .container { height:100%; } .header .headerLogo { position:absolute; top:32px; left:60px; width:283px; } .header .nav .navTop { position:absolute; top:0px; display:none; height:4px; background:#7e308e; } .header .nav .navTop { transition-duration: .5s; -ms-transition-duration: .5s; -moz-transition-duration: .5s; -webkit-transition-duration: .5s; } .header .nav { position:absolute; top:0px; right:0px; width:63%; height:120px; } .header .nav .child { position:relative; float:left; width:10%; height:120px; line-height:120px; text-align:center; color:#666; } .header .nav .child.navChildSearch { line-height:20px !important; } .header .nav .child:hover .title { color:#7D2F8D; } .header .nav .child .title { font-size:16px; color:#666; } .header .nav .child .title { transition-duration: .5s; -ms-transition-duration: .5s; -moz-transition-duration: .5s; -webkit-transition-duration: .5s; } .header .nav .child.on .title { color:#7D2F8D; } .header .nav .child .childContent { display:none; position:absolute; top:120px; width:100%; } .header .nav .child .childContent .childContentLi { background:url(../images/navchildbg.png); color:#666; font-size:14px; height:38px; line-height:38px; border-bottom:1px solid #c6c5c4; -webkit-box-shadow: 0px 2px 2px 0px rgba(125,125,125,0.2); -moz-box-shadow: 0px 2px 2px 0px rgba(125,125,125,0.2); -ms-box-shadow: 0px 2px 2px 0px rgba(125,125,125,0.2); -o-box-shadow: 0px 2px 2px 0px rgba(125,125,125,0.2); box-shadow: 0px 2px 2px 0px rgba(125,125,125,0.2); } .header .nav .child .childContent .childContentLi:hover { background:#81418a; color:#fff; } .header .nav .child .language { display:inline-block; *display:inline; *zoom:1; height:16px; line-height:16px; padding:0 8px; font-size:16px; color:#666; } .header .nav .child .language:hover { color:#7D2F8D; } .header .nav .child .language.cn { border-right:1px solid #ccc; } .header .nav .child .language.on { color:#7D2F8D; } .header .nav .child .seachIcon { cursor:pointer; } .header .list { position:relative; background:#363839; z-index:6; } .header .list .container { padding:50px 0; display:none; } .header .list .content { width:492px; } .header .list .listMTitle { color:#fff; font-size:18px; line-height:24px; padding-bottom:24px; } .header .list .listTitle { position:relative; width:100%; } .header .list .listTitle:after { content: "020"; display: block; height: 0; clear: both; visibility:hidden; } .header .list .listTitle .title { border-bottom:1px solid #999999; line-height:36px; color:#B9B9B9; font-size:14px; font-family:Arial, Helvetica, sans-serif; } .header .list .listTitle .title a { color:#B9B9B9; font-size:14px; } .header .list .listTitle .title img { margin-right:12px; } .header .list .listTitle .title .pointer { cursor:pointer; position:absolute; right:0px; top:16px; width:11px; height:11px; } .header .list .listTitle .title .pointer .sub { position:absolute; left:0px; top:5px; width:11px; height:1px; background:#999; } .header .list .listTitle .title .pointer .sub.sub2 { transform:rotate(90deg); -moz-transform:rotate(90deg); -ms-transform:rotate(90deg); -o-transform:rotate(90deg); -webkit-transform:rotate(90deg); } .header .list .listTitle .title .pointer .sub.sub2 { transition-duration: .5s; -ms-transition-duration: .5s; -moz-transition-duration: .5s; -webkit-transition-duration: .5s; } .header .list .listTitle .title .pointer.on .sub.sub2 { transform:rotate(0deg); -moz-transform:rotate(0deg); -ms-transform:rotate(0deg); -o-transform:rotate(0deg); -webkit-transform:rotate(0deg); } .header .list .listTitle .listContent { display:none; width:94%; float:right; } .header .list .addBtn { z-index:5; cursor:pointer; position:absolute; bottom:-35px; right:0; width:35px; height:35px; background:url(../images/addicon.png) no-repeat; } .header .list .addBtn .sub { position:absolute; width:10px; height:2px; background:#fff; } .header .list .addBtn .sub.sub1 { top:12px; left:22px; } .header .list .addBtn .sub.sub2 { top:12px; left:22px; transform:rotate(90deg); -moz-transform:rotate(90deg); -ms-transform:rotate(90deg); -o-transform:rotate(90deg); -webkit-transform:rotate(90deg); } .header .list .addBtn .sub.sub2 { transition-duration: .5s; -ms-transition-duration: .5s; -moz-transition-duration: .5s; -webkit-transition-duration: .5s; } .header .list .addBtn.on .sub.sub2 { transform:rotate(0deg); -moz-transform:rotate(0deg); -ms-transform:rotate(0deg); -o-transform:rotate(0deg); -webkit-transform:rotate(0deg); } .header .searchContent { display:none; position:absolute; bottom:-80px; right:0px; padding:25px; background-color: #f2efef; border-bottom:1px solid #dcdadb; border-left:1px solid #dcdadb; } .header .searchContent .seach { margin:0; } .wapNavBtn { display:none; position:absolute; top:38px; right:32px; cursor:pointer; } .wapLanguage { display:none; position:absolute; top:35px; right:120px; } .wapLanguage .language { padding:0 14px; color:#999999; font-size:28px; line-height:28px; display:inline-block; *display:inline; *zoom:1; } .wapLanguage .language.on { color:#7D2F8D; } .wapLanguage .language.cn { border-right:3px solid #bababa; } .wapNavPointer { display:none; position:absolute; top:3px; right:3px; cursor:pointer; } .crumbs { padding-top:120px; position:relative; height:55px; line-height:55px; background:url(../images/banner.jpg) repeat-x; background-position:center bottom; border-bottom:1px solid #e0e0e0; } .crumbs .title { float:left; color:#333333; font-size:20px; font-family:""微软雅黑""; } .crumbs .childs { float:right; color:#666; font-size:14px; font-family:"Hiragino Sans GB"; } .crumbs .childs a { color:#666; } .crumbs .childs span { margin:0 6px; } .main { padding:40px 0 90px 0; } .main .maxTitle { position:relative; line-height:34px; } .main .maxTitle span { position:relative; z-index:1; padding-right:18px; background:#fff; color:#7D2F8D; font-size:30px; } .main .maxTitle .sub { position:absolute; top:18px; width:100%; height:1px; width:100%; background:#d6d6d6; } .main .top { display:none; position:fixed; right:50px; bottom:300px; z-index:1; width:60px; height:60px; background:#d4d4d4; line-height:60px; text-align:center; cursor:pointer; } .main .top { transition-duration: .5s; -ms-transition-duration: .5s; -moz-transition-duration: .5s; -webkit-transition-duration: .5s; } .main .top:hover { background:#717373; } .main .top img { vertical-align:middle; } .footer { height:262px; } .footer .title { color:#dadada; font-size:16px; padding-top:40px; } .footer .head { height:222px; background:#717373; } .footer .head .left { position:absolute; top:0px; left:100px; width:300px; } .footer .head .right { position:absolute; top:0px; right:0px; width:344px; } .footer .head .right .content { margin-top:40px; } .footer .head .right .content img { margin-right:6px; } .footer .head .right .content img { transition-duration: .5s; -ms-transition-duration: .5s; -moz-transition-duration: .5s; -webkit-transition-duration: .5s; } .footer .head .right .content img:hover { transform:scale(1.1); -moz-transform:scale(1.1); -ms-transform:scale(1.1); -o-transform:scale(1.1); -webkit-transform:scale(1.1); } .footer .foot { height:40px; background:#474747; line-height:40px; text-align:center; color:#b7b7b7; font-size:12px; font-family:Arial, Helvetica, sans-serif; font-family:""微软雅黑""; } .footer .foot a { color:#b7b7b7; } @media (max-width: 639px) { .container { width:93.75%; } .mainTitle { width:150px; line-height:35px; font-size:20px; } .seach { margin-top:19px; width:150px; height:21px; } .seach .seachText { width:125px; font-size:12px; padding:0 0 0 5px; line-height:21px; height: 20px; } .seach .btn { width:22px; height:22px; line-height:22px; } .vedioContent { width:300px; height:210px; margin:-130px 0 0 -160px; padding:10px 10px 20px 10px; } .vedioContent iframe { width:100% !important; height:100% !important; } .vedioContent .vedioClose { bottom:5px; right:10px; } .header { height:50px !important; } .header .headerLogo { top:13px !important; left:16px; width:56px; } .header .nav .navTop { display:none !important; } .header .nav { display:none; top:50px; right:0px; width:100%; height:auto !important; background:#fff; padding-bottom:10px; } .header .nav .child { float:none; width:90%; text-align:left; margin:0 auto; color:#333333; background-color: #f9f9f9; border-left:1px solid #dadada; border-right:1px solid #dadada; border-bottom:1px solid #dadada; height:auto !important; line-height: 35px !important; } .header .nav .child:nth-child(2) { border-top:1px solid #dadada; } .header .nav .child .title { font-size:12px; color:#666; padding:0 2%; display: inherit; } .header .nav .child .childContent { display:none; position:relative; top:0px !important; width:100%; } .header .nav .child .childContent .childContentLi { padding:0 4%; color:#666; font-size:12px; height:35px; line-height:35px; border-top:1px solid #dadada; border-bottom:0px; } .header .nav .navChildLanguage { display:none; } .header .nav .navChildSearch { display:none; } .header .list { display:none !important; } .header .searchContent { display:none !important; } .wapNavPointer { display:block; top:3px; right:3px; } .wapNavBtn { display:block; top:19px; right:16px; width:24px; } .wapLanguage { display:block; top:17px; right:50px; } .wapLanguage .language { padding:0 2px; font-size:14px; line-height:14px; } .wapLanguage .language.cn { border-right:1px solid #bababa; } .crumbs { padding-top:50px !important; height:30px; line-height:30px; } .crumbs .title { font-size:12px; } .crumbs .childs { display:none; } .main { padding:20px 0 45px 0; } .main .maxTitle { line-height:20px; } .main .maxTitle span { padding-right:8px; font-size:18px; } .main .maxTitle .sub { top:10px; } .footer { height:auto; } .footer .title { font-size:12px; padding-top:10px; line-height:17px; } .footer .head { height:95px; } .footer .head .left { position:absolute; top:0px; left:0px; width:150px; } .footer .head .right { width:130px; } .footer .head .right .content { margin-top:16px; } .footer .head .right .content img { margin-right:3px; height:14px; } .footer .foot { height:auto; line-height:14px; font-size:12px; padding:8px 0; } .footer .foot p { width:80%; margin:0 auto; } } @media (min-width: 640px) and (max-width:1023px ) { .container { width:600px; } .mainTitle { width:248px; line-height:50px; font-size:25px; } .seach { margin-top:17px; width:245px; height:33px; } .seach .seachText { width:235px; font-size:16px; padding:0 0 0 10px; line-height:33px; } .seach .btn { width:33px; height:33px; line-height:33px; } .vedioContent { width:600px; height:420px; margin:-260px 0 0 -320px; padding:20px 20px 50px 20px; box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); -moz-box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); -ms-box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); -o-box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); -webkit-box-shadow: 0px 0px 40px 0px rgba(0,0,0,0.2); border-radius:6px; -moz-border-radius:6px; -ms-border-radius:6px; -o-border-radius:6px; -webkit-border-radius:6px; } .vedioContent iframe { width:100% !important; height:100% !important; } .vedioContent .vedioClose { position:absolute; bottom:10px; right:20px; cursor:pointer; } .header { height:73px !important; } .header .headerLogo { top:23px !important; left:31px; width:94px; } .header .nav .navTop { display:none !important; } .header .nav { display:none; top:73px; right:0px; width:100%; height:auto !important; background:#fff; padding-bottom:20px; } .header .nav .child { float:none; width:90%; text-align:left; margin:0 auto; color:#333333; background-color: #f9f9f9; border-left:1px solid #dadada; border-right:1px solid #dadada; border-bottom:1px solid #dadada; height:auto !important; line-height: 35px !important; } .header .nav .child:nth-child(2) { border-top:1px solid #dadada; } .header .nav .child .title { font-size:12px; color:#666; padding:0 2%; display: inherit; } .header .nav .child .childContent { display:none; position:relative; top:0px !important; width:100%; } .header .nav .child .childContent .childContentLi { padding:0 4%; color:#666; font-size:12px; height:35px; line-height:35px; border-top:1px solid #dadada; border-bottom:0px; } .header .nav .navChildLanguage { display:none; } .header .nav .navChildSearch { display:none; } .header .list { display:none !important; } .header .searchContent { display:none !important; } .wapNavPointer { display:block; top:3px; right:3px; } .wapNavBtn { display:block; top:29px; right:33px; width:32px; } .wapLanguage { display:block; top:29px; right:120px; } .wapLanguage .language { padding:0 14px; font-size:18px; line-height:18px; } .wapLanguage .language.cn { border-right:3px solid #bababa; } .crumbs { padding-top:73px !important; height:55px; line-height:55px; } .crumbs .title { font-size:20px; } .crumbs .childs { font-size:14px; } .crumbs .childs span { margin:0 6px; } .main { padding:40px 0 90px 0; } .main .maxTitle { line-height:34px; } .main .maxTitle span { padding-right:18px; font-size:28px; } .main .maxTitle .sub { top:18px; } .footer { height:auto; } .footer .title { font-size:16px; padding-top:18px; line-height:28px; } .footer .head { height:140px; } .footer .head .left { position:absolute; top:0px; left:0px; width:300px; } .footer .head .right { width:130px; } .footer .head .right .content { margin-top:17px; } .footer .head .right .content img { margin-right:6px; } .footer .foot { height:auto; line-height:16px; font-size:14px; padding:11px 0; } .footer .foot p { width:70%; margin:0 auto; } } @media (min-width: 1024px) and (max-width:1199px ) { .container { width:980px; } .mainTitle { width:295px; line-height:56px; font-size:36px; } .header { height:80px !important; } .header .headerLogo { top:16px !important; left:60px; width:133px; } .header .nav .navTop { height:2px; } .header .nav { height:80px !important; } .header .nav .child { height:80px !important; line-height:80px !important; } .header .nav .child .title { font-size:12px; } .header .nav .child .childContent { top:80px !important; } .header .nav .child .childContent .childContentLi { font-size:12px; height:30px; line-height:30px; } .header .nav .child .language { height:12px; line-height:12px; padding:0 4px; font-size:12px; } .header .nav .child .seachIcon { width:14px; margin-top: 33px !important; } .header .list .container { padding:40px 0; } .header .list .content { width:492px; } .header .list .listMTitle { font-size:16px; line-height:20px; padding-bottom:10px; } .header .list .listTitle .title { line-height:24px; font-size:12px; } .header .list .listTitle .title a { font-size:12px; } .header .list .listTitle .title img { margin-right:12px; } .header .list .listTitle .title .pointer { top:6px; } .crumbs { padding-top:80px !important; } } @media (min-width: 1200px) and (max-width:1439px ) { } @media (min-width: 1440px) and (max-width:1920px ) { } /*animate*/ @keyframes rightOpacityShow { 0% { transform: translateX(-80px); opacity:0; } 80% { transform: translateX(20px); } 100% { transform:translateX(0); opacity:1; } } @-moz-keyframes rotateYOpacityAn { 0% { -moz-transform: translateX(-80px); opacity:0; } 80% { -moz-transform: translateX(20px); } 100% { -moz-transform:translateX(0); opacity:1; } } @-webkit-keyframes rotateYOpacityAn { 0% { -webkit-transform: translateX(-80px); opacity:0; } 80% { -webkit-transform: translateX(20px); } 100% { -webkit-transform:translateX(0); opacity:1; } } @-o-keyframes rotateYOpacityAn { 0% { -o-transform: translateX(-80px); opacity:0; } 80% { -o-transform: translateX(20px); } 100% { -o-transform:translateX(0); opacity:1; } }

原文地址:https://www.cnblogs.com/blogst/p/10740399.html

时间: 2024-08-30 06:54:54

一段自适应的CSS代码的相关文章

背景图片全屏自适应关键css代码

html,body{ width: 100%; height: 100%; } body{ /*background-repeat: no-repeat;*/ background-size: 100% 100%; } 这个非常关键,不知道网上为什么完全搜不到,就好像没有这个知识点,搜到的都是些瞎扯淡的东西. 我一开始不知道很烦恼,原来要设置html和body的宽高都为100%,dom元素们才有一个基准,要不然怎么设置background-size都是白瞎,是否repeat根据自己需要,如果你的

高效的CSS代码(2)

——阅读笔记,欢迎纠错^_^ 内容比较零散..... 1.让浮动元素的父容器根据元素的高度而自适应高度的方法: <div class="clearfix"><div class="fl"></div></div> /*意思就是最外面的一层<div></div>是父容器,给他加上清除浮动的功能,clearfix的代码再高效的CSS代码(1)中有*/ 2.再写代码前不是要先分析一下页面的模块吗,模块

[插件]ZenCoding-HTML/CSS代码编辑利器

去年就知道了Sublime Text 2这款编辑器,当时就颇有好感,还用了一段时间来进行开发.最近,偶然知道了还有Zen Coding这样的一个插件之后,简直对这个插件以及可以支持插件的Sublime Text 爱不释手. 先说什么是Zen Coding. 如果你用过jQuery,那么一定会对选择器有深刻的印象.Zen Coding由两个核心组件构成:一个缩写扩展器:一个HTML标签匹配器. 使用Ctrl + Alt + Enter 呼出ZenCoding,我们可以用 div#content>u

css代码整理、收集

整理了一下之前用到过的css代码,实现一种效果或许有许多种写法,我这里整理了一下我个人认为兼容性比较好,结构比较简洁的代码……如有写得不对的地方敬请前辈们指点赐教一下,小弟不胜感激!此学习笔记是动态的——我日后发现有好的代码段会陆陆续续整理添加上去. css:ellipsis省略号 <style> .news{width:320px; text-overflow:ellipsis; -o-text-overflow:ellipsis; -moz-binding:url('ellipsis.xm

CSS代码语法

css 样式由选择符和声明组成,而声明又由属性和值组成,如下图所示: 选择符:又称选择器,指明网页中要应用样式规则的元素,如本例中是网页中所有的段(p)的文字将变成蓝色,而其他的元素(如ol)不会受到影响. 声明:在英文大括号"{}"中的的就是声明,属性和值之间用英文冒号":"分隔.当有多条声明时,中间可以英文分号";"分隔,如下所示: p{font-size:12px;color:red;} 注意: 1.最后一条声明可以没有分号,但是为了以后修

页面定制CSS代码初探:页面变宽 文本自动换行 图片按比缩放

一.初识博客 初写博客,先在设置里选了个喜欢的模板 第一眼就爱上了呢!那极简的风格,我喜欢!!但是,应用后,却发现... 纳尼!模板上右侧那张漂亮的图片呢?!我的怎么什么都没有.没有图片好难看啊,瞬间无爱了,设置里找了下,->博客侧边栏公告 <-,在这里,放了张宽200px的图,好看多了马上,还是有图才不会那么单调~ 二.认识CSS 过了几天,打算写篇博,发现了一个重大的问题,怎么默认的宽度这么窄?那我放图片怎么办,而且,2边留那么多空白不浪费吗,留个5%就够了吧.于是乎,开始了2天的全折腾.

CSS 代码是什么?(转)

转自:http://www.divcss5.com/rumen/r95.shtml CSS 代码是什么,什么是CSS代码? 目录 什么是CSS css代码样子(图) 作用 相关扩展阅读 一.了解什么是   -   TOP CSS全称为Cascading Style Sheets,中文翻译为“层叠样式表”,简称CSS样式表又被我们称为CSS样式,CSS样式又被作为一种能制作出各种样式网页的技术统称. 首先我们从字面理解,CSS是指CSS样式表:代码指有一定规律的单词组成. 二.CSS代码样子  

CSS代码重构

CSS代码重构的目的 我们写CSS代码时,不仅仅只是完成页面设计的效果,还应该让CSS代码易于管理,维护.我们对CSS代码重构主要有两个目的:1.提高代码性能2.提高代码的可维护性 提高代码性能 提高CSS代码性能主要有两个点:1.提高页面的加载性能提高页面的加载性能,简单说就是减小CSS文件的大小,提高页面的加载速度,尽可以的利用http缓存2.提高CSS代码性能不同的CSS代码,浏览器对其解析的速度也是不一样的,如何提高浏览器解析CSS代码的速度也是我们要考虑的 提高代码的可维护性 提高CS

30+有用的CSS代码片段

在一篇文章中收集所有的CSS代码片段几乎是不可能的事情,但是我们这里列出了一些相对于其他的更有用的代码片段,不要被这些代码的长度所吓到,因为它们都很容易实现,并且具有良好的文档.除了那些解决常见的恼人的问题外,也包含了一些解决新问题的新技术. 1. 垂直对齐 如果你之前遇到过这个问题,你就应该知道它是多么的烦人,幸运的是,现在你可以使用CSS3变换来解决这个问题: .vc{ position: relative; top: 50%; -webkit-transform: translateY(-