一个标签可以有多个css样式
浏览器处理冲突的能力,如果一个属性通过两个相同的选择器设置到这个元素上,会根据样式的层叠规则
样式的层叠规则——按照样式的声明顺序来层叠的【就近原则】
选择器必须是同一种
样式不冲突不会层叠
子标签会继承父标签的某些样式,比如文本颜色和字号
权重
继承的权重是0——最低
行内样式的权重是100
权重相同的——就近原则
!important命令——无限大
css权重公式——贡献值
继承、*——0000
标签选择器——0001
类、伪类选择器——0010
id选择器——0100
行内样式——1000
!important——无穷大
width,height——大于无穷大
权重不能被继承
贡献值是没有进位的
如果同时有!important与max-width,max-height
!important是不管用的
✒️常用单位
px像素:最常用
em:绝对单位,由父类的字号决定,比如父级的字号是16px,可以设置成2em(32px)
rem:绝对单位,由整个html的字号决定的,页面的字号也会发生变化
百分比:相对于父元素的比例
✒️字体大小
/* 字体大小 */
1
font-size: 20px;
/* 字体样式 /
font-style: italic;
/ 字体粗细 /
font-weight: bold;
/ 字体修饰 /
text-decoration:line-through;
/ 字体 /
font-family: monospace;
/ 复合属性 */
font: 130px italic bolder ;
✒️背景
一般情况下不要既有背景颜色又有背景图片
/* 背景颜色 */
/* background-color: rgba(255,255,0); /
/ 设置颜色可以用——英语、十六进制、如果部、rgb、rgba /
width: 1200px;
height: 1200px;
/ 背景图片 /
background-image: url(…/…/2022-8-22/morning/img/a.webp);
/ 背景大小 /
background-size: 1200px;
/ 背景图片不重复 /
background-repeat:no-repeat;
/ 背景的位置 */
background-position: center;
✒️列表
list-style-type:lower-greek;
list-style-image: url(../../2022-8-22/morning/img/a.webp);
1
2
✒️圆角
width: 200px;
height: 200px;
background-color: yellow;
/* 圆角 */
border-radius:15px;
/* 左下圆角 */
border-bottom-left-radius: 68px;
/* 虚线 */
border-style: dashed;
区块属性
盒子模型
width: 300px;
height: 300px;
background: rgb(238, 107, 107);
/* 外边距 */
margin : 100px;
/* 盒子的边框线宽度,颜色,边框线 */
border: 10px blueviolet solid;
/* 内边距 */
padding-top: 10px;
/* 保证盒子的大小是300*300 盒子的外边距是 不包括的 */
box-sizing: border-box;
/* 保证当前div的尺寸是300*300 不包含内边距和边框线 */
box-sizing: content-box;
在网页中将窗体自上到下的分成多行
在每一行从左到右的顺序排列元素——即为文档流
网页默认的布局方式
定位position
static:文档流,默认的
absolute:绝对定位
相对于一个父元素的绝对定位
当设置了绝对定位之后,原来的元素脱离了文档流。会在页面上浮起来。
relative:相对定位
相对于上一个元素的位置的定位
fixed:固定定位
/* 居中 */
margin: center;
/* 固定定位 */
position: fixed;
/* z轴的索引 */
z-index:1080;
【子绝父相】
子元素是绝对定位
父元素是相对定位
【定位left与盒子模型margin-left有什么区别】
定位left是相对于父元素的位置,margin是相对于自己的位置
left是定位的属性
可见性
visibility:
visibility: hidden; /*隐藏*/
1
/* 溢出策略 */
overflow:scroll;
div{
width: 50px;
height: 500px;
overflow: hidden;
display: inline-block;
}
div:hover{
overflow:visible;
width:885px;
}
/延迟/
div{
/* 针对于火狐浏览器 /
/ -moz-transform: ; /
/ 针对于Safari 和Google /
/ -webkit-transform: ; /
/ 针对于Opera /
/ -o-transform: ; */
/* Transition -延迟转换*/
width: 100px;
height: 100px;
background-color: orange;
transition: width 1s 3s,height 3s ease-in,background-color ease-out 3s;
}
div:hover{
width: 500px;
height: 500px;
background-color: aqua;
}
transition与animate的区别
transition只能通过固定的属性来开始与结束值
animate可以一帧一帧的去实现效果
.size {
width: 200px;
height: 200px;
border-top-right-radius: 65px;
border-bottom-left-radius: 65px;
background-color: green;
position: relative;
left: 100px;
top: 100px;
}
.size1 {
width: 200px;
height: 200px;
border-bottom-right-radius: 65px;
border-top-left-radius: 65px;
background-color: orange;
position: relative;
left: 100px;
}
.size2 {
width: 200px;
height: 200px;
border-bottom-right-radius: 65px;
border-top-left-radius: 65px;
background-color: blue;
position: relative;
right: 0px;
top: 100px;
}
.size3 {
width: 200px;
height: 200px;
border-top-right-radius: 65px;
border-bottom-left-radius: 65px;
background-color: red;
}
.a {
width: 300px;
height: 300px;
background: rgb(5, 230, 5);
border-top-left-radius: 50px;
}
.b {
width: 300px;
height: 300px;
background: rgb(12, 101, 235);
border-top-right-radius: 50px;
}
.c {
width: 300px;
height: 300px;
background: rgb(246, 136, 33);
border-bottom-left-radius: 50px;
}
.d {
width: 300px;
height: 300px;
background: rgb(238, 107, 107);
border-bottom-right-radius: 50px;
}
<table border="0" cellspacing="0px">
<tr>
<td>
<div class="a">
<div class="size back"></div>
</div>
</td>
<td>
<div class="b">
<div class="size2 back"></div>
</div>
</td>
</tr>
<tr>
<td>
<div class="c">
<div class="size1 back"></div>
</div>
</td>
<td>
<div class="d">
<div class="size3 back"></div>
</div>
</td>
我在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
3月26日,映宇宙(HK:03700,即“映客”)发布截至2022年12月31日的2022年度业绩财务报告。财报显示,映宇宙2022年的总营收为63.19亿元,较2021年同期的91.76亿元下降31.1%。2022年,映宇宙的经营亏损为4698.7万元,2021年同期则为净利润4.57亿元;期内亏损(净亏损)为1.68亿元,2021年同期的净利润为4.33亿元;非国际财务报告准则经调整净利润为3.88亿元,2021年同期为4.82亿元,同比下降19.6%。 映宇宙在财报中表示,收入减少主要是由于行业竞争加剧,该集团对旗下产品采取更为谨慎的运营策略以应对市场变化。不过,映宇宙的毛利率则有所提升
有没有一种方法可以在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-用