css的使用是让网页具有统一美观的页面,css层叠样式表,简称样式表,文件后缀名.css
css的规则由两部分构成:选择器以及一条或者多条声明
选择器:通常是需要改变的HTML元素
声明:由一个属性和一个值组成,每个属性有一个值,属性和值使用类似key:value的形式(如下方h1就是选择器,color就是属性,rebeccapurple就是值,属性和值成为一条声明)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
h1{
color: rebeccapurple;
font-size: 10px;
}
</style>
</head>
<body>
<h1>Welcome CSS</h1>
</body>
</html>
行内样式:在需要改变的标签内使用style属性,让style属性包含任何css的属性
注:缺点是缺乏整体统一性,不利于维护
<h1 style="background-color: blueviolet; font-size: 20px;">Welcome CSS</h1>
内部样式,在单个文档需要的特殊样式,如上方css概念中的例子,在文档头部使用style标签增加样式
注:可以让单个页面css代码具有统一性,但多个页面容易混乱
外部样式:当样式应用于多个页面,外部样式在每个需要使用的页面通过link标签链接到样式表。link标签在文档头部
建立一个public.css文件,写外部样式
p{
color: aquamarine;
font-size: 20px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./public.css">
</head>
<body>
<p>产品</p>
</body>
</html>
全局选择器:优先级最低,一般做初始化样式
*{
color: blue;
}
用通配符 *
元素选择器:选择页面所有相同类型标签,用于描述这些类型的共性,无论这个标签藏的多深都能被选择上
HTML文档中的p、div、img等等标签
p{
color: blue;
}
类选择器:用圆点.来定义,针对相同类的标签,类名不能用数字开头,同一个标签可以使用多个类选择器,用空格隔开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.classone{
color: red;
font-size: 30px;
}
.classtwo{
background-color: black;
height: 100px;
}
</style>
</head>
<body>
<h1 class="classone classtwo">标题</h1>
</body>
</html>
ID选择器:针对特定id标签来使用,只能使用一次,用#来定义,不能用数字开头
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#mytext{
color: red;
}
</style>
</head>
<body>
<p id="mytext">文本</p>
</body>
</html>
合并选择器:多个标签提取共同样式,减少重复代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#mytext,.mytitle{
color: red;
}
.mytitle{
background-color: black;
}
</style>
</head>
<body>
<p id="mytext">文本</p>
<h1 class="mytitle">标题</h1>
</body>
</html>
选择器优先级:行内样式 > ID选择器 > 类选择器 > 元素选择器
包括颜色、大小、加粗、文字样式
颜色
<p style="color: red;">字体颜色</p>
<p style="color: #fff000;">字体颜色</p>
<p style="color: rgb(0,0,0);">字体颜色</p>
<p style="color: rgba(0, 0, 0, 1);">字体颜色</p>
大小
<p style="color: red;font-size: 30px;">字体颜色</p>
粗细
数值范围100-900,400是默认值,700等同于bold
<p style="font-weight: bold;">字体颜色</p>
<p style="font-weight: bolder;">字体颜色</p>
<p style="font-weight: lighter;">字体颜色</p>
<p style="font-weight: 900;">字体颜色</p>
文字样式
<p style="font-style: normal;">字体颜色</p>
<p style="font-style: italic;">字体颜色</p>
<p style="font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;">字体颜色</p>
| 属性 | 值 |
|
background-color
|
背景颜色 |
|
background-image
|
背景图片 |
|
background-positio
|
图片位置 |
|
background-repeat
|
图片填充 |
|
background-size
|
图片大小 |
| 属性 | 值 |
| repeat | 默认值 |
| repeat-x | 水平方向平铺 |
| repeat-y | 垂直方向平铺 |
| no-repeat | 不平铺 |
background-size :可以使用数值设置宽度和高度,也可以使用百分比,最常用的是两个值cover(保持图片横纵比将图片覆盖背景最小大小),contain(保持图片横纵比将图片覆盖背景最大大小)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1,.box2{
width: 600px;
height: 600px;
}
.box1{
background-image: url(./u=1175012548\,1449685026&fm=253&fmt=auto&app=138&f=JPEG.webp);
background-repeat: no-repeat;
background-size: cover;
}
.box2{
background-color:rebeccapurple;
background-position: left top;
}
</style>
</head>
<body>
<div class="box1">背景1</div>
<div class="box2">背景2</div>
</body>
</html>
文本对齐方式:居中、靠左、靠右
<h1 style="text-align: center;">h1</h1>
<h2 style="text-align: left;">h2</h2>
<h3 style="text-align: right;">h3</h3>
文本添加下划线、上划线和删除线
<h1 style="text-decoration: underline;">h1</h1>
<h2 style="text-decoration: overline;">h2</h2>
<h3 style="text-decoration: line-through;">h3</h3>
文本大小写
<h1 style="text-transform: capitalize;">h1</h1>
<h2 style="text-transform: uppercase;">h2</h2>
<h3 style="text-transform: lowercase;">h3</h3>
首行文本缩进
<h1 style="text-transform: capitalize; text-indent: 100px;">h1</h1>
表格边框、颜色、边框折叠
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
table,td{
border: 1px solid red;
}
table{
border-collapse: collapse<!-- 折叠边框 -->;
padding: 20px;
}
</style>
</head>
<body>
<table>
<tr>
<td>单元格</td>
<td>单元格</td>
<td>单元格</td>
</tr>
<tr>
<td>单元格</td>
<td>单元格</td>
<td>单元格</td>
</tr>
<tr>
<td>单元格</td>
<td>单元格</td>
<td>单元格</td>
</tr>
</table>
</body>
</html>
后代选择器:所有所有被A包含的B元素,用空格分开A B{ }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
ul li{
color: #fff000;
}
</style>
</head>
<body>
<ul>
<li>A</li>
<li>B</li>
</ul>
</body>
</html>
子代选择器:只对所有A标签的直接子标签B起作用,A>B{ }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div>span{
color: #fff000;
}
</style>
</head>
<body>
<div>
<span>A</span>
<h1><span>B</span></h1>
<span>C</span>
</div>
</body>
</html>
相邻兄弟选择器:选择紧跟A标签后的B元素,选择向下相邻的第一个兄弟元素, A+B{ }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
span+p{
color: #fff000;
}
</style>
</head>
<body>
<div>
<span>A</span>
<p>B</p>
<p>C</p>
</div>
</body>
</html>
通用兄弟选择器:选择A之后的所有兄弟元素B作用多个,A~B{ }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
span~p{
color: #fff000;
}
</style>
</head>
<body>
<div>
<span>A</span>
<p>B</p>
<p>C</p>
</div>
</body>
</html>
css的盒子包括外边距(margin),边框(border),内边距(padding),实际内容(content)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
width: 100px;
height: 100px;
background-color: yellow;
padding: 50px 10px;
border: 5px solid red;
margin: 80px;
}
</style>
</head>
<body>
<div>
content
</div>
</body>
</html>
弹性盒子是由弹性容器和弹性子元素组成,弹性容器通过设置display属性值为flex来定义弹性容器,弹性盒子只对弹性子元素生效
通过flex-direction来设置子元素在容器中的位置(默认水平排列)row左对齐;row-reverse翻转右对齐;column纵向排列;column-reverse翻转纵向排列
子元素可以通过flex来分配空间
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container{
width: 500px;
height: 500px;
background-color: black;
display: flex;
justify-content: center;
align-items: center;
}
.box1,.box2,.box3{
width: 100px;
height: 100px;
}
.box1{
background-color: red;
flex: 10%;
}
.box2{
background-color: yellow;
flex: 30%;
}
.box3{
background-color: blue;
flex: 60%;
}
</style>
</head>
<body>
<div class="container">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</div>
</body>
</html>
增加一个浮层来放置内容
| float的值 | 值描述 |
| left | 向左浮动 |
| right | 向右浮动 |
浮动以后相当于在页面增加一个浮层来放置内容
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1{
width: 100px;
height: 100px;
background-color: red;
float: left;
}
.box2{
width: 200px;
height: 200px;
background-color: yellow;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
</body>
</html>
浮动元素会造成父元素高度塌陷,如下方例子,不设置父元素的高度,浮动就无法把父元素撑起来
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1{
width: 200px;
background-color: red;
}
.box2{
width: 100px;
height: 100px;
background-color: yellow;
float: left;
}
</style>
</head>
<body>
<div class="box1">
<div class="box2"></div>
</div>
</body>
</html>
解决方案可以设置父元素的高度,也可以通过清除浮动,通过在父标签加overflow:fidden
.box1{
width: 200px;
background-color: red;
overflow: hidden;
clear: both;
}
除了造成父元素塌陷,同样也会影响后续元素,例子如下,我们同样无法看到box3,因为被浮动的box2遮挡
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1{
width: 200px;
background-color: red;
overflow: hidden;
clear: both;
}
.box2{
width: 100px;
height: 100px;
background-color: yellow;
float: left;
}
.box3{
width: 100px;
height: 100px;
background-color: black;
}
</style>
</head>
<body>
<div class="box1">
<div class="box2"></div>
<div class="box3"></div>
</div>
</body>
</html>
解决方法就是,在需要处理的地方加上clear:both
.box3{
width: 100px;
height: 100px;
background-color: black;
clear: both;
}
| position的值 | 值描述 |
| relative | 相对定位 |
| absolute | 绝对定位 |
| fixed | 固定定位 |
设置后可以通过left、top、right、bottom来调整,每用一个position就会增加一个浮层:
固定定位是不会随着页面移动变动位置的,永远在固定位置
相对定位和绝对定位是根据具有定位的父元素进行定位的,如果父级没有定位就会根据页面来定位
相对定位是不脱离文档流的,绝对定位和固定定位都是脱离文档流的
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
width: 100px;
height: 100px;
background-color: red;
position: relative;
left: 100px;
top: 100px;
}
.box1{
width: 100px;
height: 100px;
background-color: black;
position: absolute;
left: 100px;
top: 300px;
}
</style>
</head>
<body>
<div></div>
<div class="box1"></div>
</body>
</html>
调整位置顺序通过z-index,如下方例子,原本是黑色遮盖红色,如果想调整为红色在上,只需要增加z-index
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
width: 100px;
height: 100px;
background-color: red;
position: relative;
left: 100px;
top: 100px;
}
.box1{
width: 100px;
height: 100px;
background-color: black;
position: absolute;
left: 100px;
top: 100px;
}
</style>
</head>
<body>
<div></div>
<div class="box1"></div>
</body>
</html>
z-index大的值在上方
div{
width: 100px;
height: 100px;
background-color: red;
position: relative;
left: 100px;
top: 100px;
z-index: 2;
}
.box1{
width: 100px;
height: 100px;
background-color: black;
position: absolute;
left: 100px;
top: 100px;
z-index: 1;
}
圆角特性:使用属性border-radius
规则:
一个值:四个圆角值相同
两个值:第一个值表示左上和右下的值,第二个值是右上和左下
四个值:第一个值左上,第二个值右上,第三个值右下,第四个值左下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./public.css">
<style>
.box1,.box2,.box3{
width: 100px;
height: 100px;
background-color: black;
margin: 100px;
}
.box1{
border-radius: 80%;
}
.box2{
border-radius: 50px 100px;
}
.box3{
border-radius: 10px 20px 30px 50px;
}
</style>
</head>
<body>
<div class="box1">box1</div>
<div class="box2">box2</div>
<div class="box3">box3</div>
</body>
</html>
阴影
| box-shadow的值 | 描述 |
| h-shadow | 水平阴影位置 |
|
v-shadow |
垂直阴影位置 |
| blur | 模糊距离 |
| color |
阴影颜色 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./public.css">
<style>
.box1,.box2,.box3{
width: 100px;
height: 100px;
background-color: black;
margin: 100px;
}
.box1{
box-shadow: 10px 10px 100px red;
}
</style>
</head>
<body>
<div class="box1"></div>
</body>
</html>
使元素从一种样式逐渐变成另一种样式的效果
用百分号或者关键词from和to来规定发生的时间
| animation的值 | 描述 |
| name | 动画名称 |
| duration | 动画持续时间 |
| timing-function | 动画效果的速率 |
| delay | 延迟执行 |
| iteration-count | 循环次数,infinite为无限次数 |
| direction | 动画播放的方向 |
| animation-play-state | 控制动画的播放状态 |
box1设置一个鼠标滑动过去动画暂停
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./public.css">
<style>
.box1{
width: 100px;
height: 200px;
background-color: green;
animation: myAnimation 5s linear 0s infinite ;
}
.box2{
width: 100px;
height: 200px;
background-color: pink;
animation: mySecAnim 5s linear 0s infinite ;
}
.box1:hover{
animation-play-state: paused;
}
@keyframes myAnimation{
from{
background-color: red;
}
to{
background-color: black;
}
}
@keyframes mySecAnim{
10%{
background-color: rebeccapurple;
}
50%{
background-color: blue;
}
100%{
background-color: gray;
}
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
</body>
</html>
呼吸效果展示
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./public.css">
<style>
.box1{
width: 100px;
height: 200px;
margin: 100px;
border-radius: 50%;
background-color: green;
box-shadow: 10px 10px 40px black;
animation: breathe 5s linear 0s infinite alternate;
}
.box1:hover{
animation-play-state: paused;
}
@keyframes breathe {
10%{
opacity: 0.2;
box-shadow: 10px 10px 40px green;
}
50%{
opacity: 0.5;
box-shadow: 10px 10px 40px pink;
}
100%{
opacity: 1;
box-shadow: 10px 10px 40px gold;
}
}
</style>
</head>
<body>
<div class="box1"></div>
</body>
</html>
媒体查询
根据页面大小展示不同页面
如下根据不同页面大小显示不同颜色和不同标签
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./public.css">
<style>
.box1{
width: 100px;
height: 200px;
margin: 100px;
border-radius: 50%;
background-color: green;
box-shadow: 10px 10px 40px black;
}
@media screen and (max-width: 768px) {
.box1{
background-color: red;
}
.p1{
display: none;
}
.p2{
display: none;
}
}
@media screen and (min-width: 768px) and (max-width:996px){
.box1{
background-color: aqua;
}
.p1{
display: none;
}
.p2{
display: block;
}
}
@media screen and (min-width: 996px) {
.box1{
background-color: peru;
}
.p1{
display: block;
}
.p2{
display: block;
}
}
</style>
</head>
<body>
<div class="box1"></div>
<p class="p1">p标签1</p>
<p class="p2">p标签2</p>
</body>
</html> 我在MiniTest::Spec和Capybara中使用以下规范:find_field('Email').must_have_css('[autofocus]')检查名为“电子邮件”的字段是否具有autofocus属性。doc说如下:has_css?(path,options={})ChecksifagivenCSSselectorisonthepageorcurrentnode.据我了解,字段“Email”是一个节点,因此调用must_have_css绝对有效!我做错了什么? 最佳答案 通过JonasNicklas得到了答案:No
我有一个div,它根据表单是否正确提交而改变。我想知道是否可以检查类的特定元素?开始元素看起来像这样。如果输入不正确,添加错误类。 最佳答案 试试这个:browser.div(:id=>"myerrortest").class_name更多信息:http://watir.github.com/watir-webdriver/doc/Watir/HTMLElement.html#class_name-instance_method另一种选择是只查看具有您期望的类的div是否存在browser.div((:id=>"myerrortes
我开始了一个新的Rails3.2.5项目,Assets管道不再工作了。CSS和Javascript文件不再编译。这是尝试生成Assets时日志的输出:StartedGET"/assets/application.css?body=1"for127.0.0.1at2012-06-1623:59:11-0700Servedasset/application.css-200OK(0ms)[2012-06-1623:59:11]ERRORNoMethodError:undefinedmethod`each'fornil:NilClass/Users/greg/.rbenv/versions/1
rails新手。只是想了解\assests目录中的这两个文件。例如,application.js文件有如下行://=requirejquery//=requirejquery_ujs//=require_tree.我理解require_tree。只是将所有JS文件添加到当前目录中。根据上下文,我可以看出requirejquery添加了jQuery库。但是它从哪里得到这些jQuery库呢?我没有在我的Assets文件夹中看到任何jquery.js文件——或者直接在我的整个应用程序中没有看到任何jquery.js文件?同样,我正在按照一些说明安装TwitterBootstrap(http:
我正在尝试消除使用Bootstrap3的Rails4元素中的glyphicon错误。我没有使用任何Bootstrapgem将其添加到Assets管道中。我手动将bootstrap.css和bootstrap.js添加到各自的app/assets目录下,分别添加到application.css和application.js什么的我现在在网络浏览器的控制台中看到以下内容:GEThttp://localhost:3000/fonts/glyphicons-halflings-regular.woff404(NotFound)localhost/:1GEThttp://localhost:30
我有一个使用twitterbootstrap和sass的Rails元素。scss文件结构化到文件夹中,所以我有更好的概述。现在我想为包含我的颜色等的全局变量定义一个文件,并将这些值传递给其他文件,这样我就有更少的冗余代码。虽然所有代码都已正确导入和应用,变量不起作用。这是当前的设置:样式表/application.css.scss/**=require_self*=require_tree*//*stylesheets/||–base/||–_reset.scss#Reset/normalize||–_typography.scss#Typographyrules||–componen
有没有一种方法可以在jekyll站点中包含自定义css标签,同时将markdown用于入口文件?例如,当我想突出显示某个段落时? 最佳答案 Markdown和YAMLFrontMatter都内置了这个。但你可以自己制作。比如说,您有foo.css想要包含在某些帖子中。在_posts/2013-02-03-higligting-foo.markdown中:---css:footitle:"DrupalImagecachesecurityvulnarabilitywithDDOSattackexplained"tags:[drupal,
我在一台Windows764位机器上使用Sass和Ruby(最新版本),我正在我的家庭服务器上处理一个共享文件夹。(但是,我不得不承认问题本身也出现在服务器上,因为我试图安装Ruby并直接-watch服务器上的文件)。问题如下:如果我第一次保存,检测到变化,我的style.css被直接覆盖。之后,我总是需要保存多达7次才能覆盖style.css。每次都会检测到更改,但不会编译任何内容。这是一个屏幕:>>>Sassiswatchingforchanges.PressCtrl-Ctostop.overwritestyle.css>>>Changedetectedto:E:/Websites
是否有一个SASS扩展可以采用SASS样式表,找到中性属性(例如border-radius)并为其输出所有特定于供应商的属性(例如-webkit-border-radius等)自动?我真的不想手动创建所有混入,也不想手动编写代码。我确定一定有这样的扩展名,但我找不到它。帮忙? 最佳答案 有一个非常好的gem可以满足您的需求。它叫做Bourbon它不会用特定于供应商的css替换您的css,因为它可以像SASS一样工作。它基本上是一个正确生成跨浏览器css的mixin集合。 关于ruby-用
CSSSpriting确实可以提高性能,但它并不是最容易阅读和维护的东西。是否有任何工具可以让我单独对图像进行编码,然后将它们聚合起来并用正确的蒙太奇子集替换HTML?我特别考虑RubyonRails插件,但如果有其他语言的包,我很乐意移植它。 最佳答案 SmartSprites试一试。 关于ruby-on-rails-是否有一个库可以自动进行CSSspriting?,我们在StackOverflow上找到一个类似的问题: https://stackoverf