PbootCMS模版
  • 微信
当前位置:首页 >> 建站学院 >> Web前端

建站前端常用代码——CSS篇

作者:玄北 时间:2023-02-05 阅读数:887人阅读

Css模块居中代码:

margin:0 auto;

Css文字居中代码:

text-align:center;

Css文字垂直居中:

line-height:300px;

Css文字加阴影效果:

text-shadow:2px 2px #FF0000;

背景图片代码:

style="background-image:url(images/a.jpg)"

背景色代码:

style="background:#000;"

在新页面打开链接

target="_blank"

加上边距:

padding-top

加下边距:

padding-bottom

加左边距:

padding-left

加右边距:

padding-right

li标签去除小黑点:

list-style:none;

Li标签竖向排列改横向:

float:left;

Css增加文字间距代码:

letter-spacing

a元素隐藏下划线:

text-decoration:none

文字加粗:

font-weight

文字放大:

<big></big>

文字大小:

font-size:14px;

设置在最上层显示:

position: absolute;z-index: 1;

首行缩进2字符:

text-indent: 2em;

块元素转换为行内元素:

display:inline-block

加圆角:

border-radius:2px 2px 2px 2px;

css圆角边框代码加阴影:

box-shadow: darkgrey 10px 10px 30px 5px ;

水平线:

<hr />

css隐藏页面元素

display: none;

Css显示页面元素:

display:block

手机版文本自动换行:

word-break: break-all;

模块换行代码:

flex-wrap: wrap;

加边框:

border: solid 1px #f21c64;

修改input默认样式

input::-webkit-input-placeholder

关闭搜索框(input)输入状态下的背景色:

form中添加autocomplete="off"

鼠标放上变成手:

cursor: pointer;

模块出现动画效果(css

<style>
transition: all 0.5s;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
    -ms-transition: all 0.5s;
-o-transition: all 0.5s;
</style>

媒体查询

@media screen and (max-width: 300px) {
    body {
        background-color:lightblue;
    }
}

网站整体变黑白效果

<style>
html {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
_filter:none;
}
</style>

1first-child

first-child表示选择列表中的第一个标签。代码如下:

li:first-child{background:#090}

上面的意思是,li 列表中的 第一个li模块的背景颜色。

2last-child

last-child表示选择列表中的最后一个标签,代码如下:

li:last-child{background:#090}

3nth-child(3)

表示选择列表中的第3个标签,代码如下:

li:nth-child(3){background:#090}

上面代码中的3也可以改成其它数字,如45等。想选择第几个标签,就填写几。

4nth-child(2n)

这个表示选择列表中的偶数标签,即选择 2、第4、第6…… 标签。

5nth-child(2n-1)

这个表示选择列表中的奇数标签,即选择 1、第3、第5、第7……标签。

6nth-child(n+3)

这个表示选择列表中的标签从第3个开始到最后。

7nth-child(-n+3)

这个表示选择列表中的标签从03,即小于3的标签。

8nth-last-child(3)

这个表示选择列表中的倒数第3个标签。

图片自动裁剪cssobject-fit: cover;


部分窗口展示滑动背景图:

.元素名 {
height: 334px;
opacity: 0.5;
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center center;
background-image: url(img/indexlxfsbjt.jpg);
}

over~~~

转载请注明——本文源自【玄北博客】www.xuanbeiweb.cn

免责声明:本站部分文章、数据、图片来自互联网,

如果侵犯了你的权益请来信告知我们删除,否则不承担相应法律责任。邮箱:monan@xuanbeiweb.cn

标签: CSS 前端 代码
玄北头像

玄北

Hi~如果您正好看到这里,可以扫一扫微信二维码加我为好友,我是一个喜欢交朋友的人,我知道您也是哦~

玄北微信

发表评论:

评论记录:

暂无评论——欢迎您的点评!