前端常用的CSS代碼

2021-02-16 執行上下文

本文首發於個人博客:故事膠片,可在底部查看原文前往博客,轉載請署名。

Git地址:

https://github.com/jiaopianjun/JsCode 厚臉求 star

1、垂直居中對齊

.vc {

position: absolute;

top: 50%;

left: 50%;

transform: translate(-50%, -50%);

}

.vc {

position:absolute;

top: 50%;

left: 50%;

width: 100px;

height: 100px;

margin:-50px 0 -50px;

}

2、全屏顯示

html,

body {

position: fixed;

width: 100%;

height: 100%;

}

div {

height: 100%;

}

3、不同a標籤連結使用不同樣式

// link

a[href^="http://"]{

background: url(link.gif) no-repeat center right;

}

// emails

a[href^="mailto:"]{

background: url(email.png) no-repeat center right;

}

// pdfs

a[href$=".pdf"]{

background: url(pdf.png) no-repeat center right;

}

4、圖像灰度

img {

filter: gray;

-webkit-filter: grayscale(1);

}

5、背景漸變動畫

bg {

background-image: linear-gradient(#5187c4, #1c2f45);

background-size: auto 200%;

background-position: 0 100%;

transition: background-position 0.5s;

}

bg:hover {

background-position: 0 0;

}

6、長文本自動換行

pre {

white-space: pre-line;

word-wrap: break-word;

}

7、模糊文本

.text {

filter: blur(1px);

}

8、用CSS動畫實現省略號動畫

.point:after {

overflow: hidden;

display: inline-block;

vertical-align: bottom;

animation: ellipsis 2s infinite;

content: "\2026";

}

@keyframes ellipsis {

from {

width: 2px;

}

to {

width: 15px;

}

}

9、樣式重置

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {

margin: 0;

padding: 0;

border: 0;

font-size: 100%;

font: inherit;

vertical-align: baseline;

outline: none;

-webkit-box-sizing: border-box;

-moz-box-sizing: border-box;

box-sizing: border-box;

}

html { height: 101%; }

body { font-size: 62.5%; line-height: 1; font-family: Arial, Tahoma, sans-serif; }

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }

ol, ul { list-style: none; }

blockquote, q { quotes: none; }

blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }

strong { font-weight: bold; }

table { border-collapse: collapse; border-spacing: 0; }

img { border: 0; max-width: 100%; }

p { font-size: 1.2em; line-height: 1.0em; color: #333; }

10、清除浮動

.clearfix:before, .container:after { content: ""; display: table; }

.clearfix:after { clear: both; }

.clearfix { zoom: 1; }

11、css元素透明

.transparent {

filter: alpha(opacity=50);

-khtml-opacity: 0.5;

-moz-opacity: 0.5;

opacity: 0.5;

}

12、CSS引用樣式

blockquote {

background: #f9f9f9;

border-left: 10px solid #ccc;

margin: 1.5em 10px;

padding: .5em 10px;

quotes: "\201C""\201D""\2018""\2019";

}

blockquote:before {

color: #ccc;

content: open-quote;

font-size: 4em;

line-height: .1em;

margin-right: .25em;

vertical-align: -.4em;

}

blockquote p {

display: inline;

}

13、個性圓角

.borderRadius {

border-radius: 4px 3px 6px 10px;

}

.borderRadius {

border-top-left-radius: 4px;

border-top-right-radius: 3px;

border-bottom-right-radius: 6px;

border-bottom-left-radius: 10px;

}

14、通用媒體查詢

@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {

/* Styles */

}

@media only screen and (min-width : 321px) {

/* Styles */

}

@media only screen and (max-width : 320px) {

/* Styles */

}

/* iPad */

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {

/* Styles */

}

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {

/* Styles */

}

@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {

/* Styles */

}

/* 桌面 */

@media only screen and (min-width : 1224px) {

/* Styles */

}

@media only screen and (min-width : 1824px) {

/* Styles */

}

@media only screen and (-webkit-min-device-pixel-ratio:1.5), only screen and (min-device-pixel-ratio:1.5) {

/* Styles */

}

15、自定義文本選擇

::selection { background: #e2eae2; }

16、圖片邊框偏光

img.polaroid {

background:#000;

border:solid #fff;

border-width:6px 6px 20px 6px;

box-shadow:1px 1px 5px #333;

-webkit-box-shadow:1px 1px 5px #333;

-moz-box-shadow:1px 1px 5px #333;

height:200px;

width:200px;

}

17、錨連結偽類

a:link { color: blue; }

a:visited { color: purple; }

a:hover { color: red; }

a:active { color: yellow; }

18、全屏背景圖

html {

background: url('bg.jpg') no-repeat center center fixed;

background-size: cover;

}

19、內容垂直居中

.center {

min-height: 6.5em;

display: table-cell;

vertical-align: middle;

}

20、強制出現垂直滾動條

html { height: 101% }

21、CSS3漸變模板

.bg {

background: #629721;

background-image: -webkit-gradient(linear, left top, left bottom, from(#83b842), to(#629721));

background-image: linear-gradient(top, #83b842, #629721);

}

22、@font-face引用

@font-face {

font-family: 'MyWebFont';

src: url('webfont.eot');

src: url('webfont.eot?#iefix')

url('webfont.woff') format('woff'),

url('webfont.ttf') format('truetype'),

url('webfont.svg#svgFontName') format('svg');

}

body {

font-family: 'MyWebFont', Arial, sans-serif;

}

23、連接CSS3元素

p {

position:relative;

z-index:1;

padding: 10px;

margin: 10px;

font-size: 21px;

line-height: 1.3em;

color: #fff;

background: #ff0030;

box-shadow: 0 0 0 4px #ff0030, 2px 1px 6px 4px rgba(10,10,0,.5);

-webkit-border-radius: 3px;

-moz-border-radius: 3px;

border-radius: 3px;

}

p:before {

content: "";

position: absolute;

z-index: -1;

top: 3px;

bottom: 3px;

left :3px;

right: 3px;

border: 2px dashed #fff;

}

p a {

color: #fff;

text-decoration:none;

}

p a:hover, p a:focus, p a:active {

text-decoration:underline;

}

24、CSS斑馬線

tbody tr:nth-child(odd) {

background-color: #ccc;

}

25、 css&符號

.amp {

font-family: Baskerville, 'Goudy Old Style', Palatino, 'Book Antiqua', serif;

font-style: italic;

font-weight: normal;

}

26、內盒陰影

.div {

box-shadow: inset 2px 0 4px #000;

}

27、外盒陰影

.div {

box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);

}

28、三角形列表項目符號

ul {

margin: 0.75em 0;

padding: 0 1em;

list-style: none;

}

li:before {

content: "";

border-color: transparent #111;

border-style: solid;

border-width: 0.35em 0 0.35em 0.45em;

display: block;

height: 0;

width: 0;

left: -1em;

top: 0.9em;

position: relative;

}

29、固定寬度的居中布局

.div {

width: 800px;

margin: 0 auto;

}

30、CSS3列文本

.columnsText {

text-align: justify;

-webkit-column-count: 3;

-webkit-column-gap: 12px;

-webkit-column-rule: 1px solid #c4c8cc;

}

31、CSS固定頁腳

footer {

position: fixed;

left: 0px;

bottom: 0px;

height: 30px;

width: 100%;

background: #444;

}

32、設置瀏覽器最小高度

.div{

min-height: 550px;

height: auto !important;

height: 550px;

}

33、CSS3輸入效果

input[type=text] {

transition: all 0.30s ease-in-out;

outline: none;

padding: 3px 0px 3px 3px;

margin: 5px 1px 3px 0px;

border: 1px solid #ddd;

}

input[type=text]:focus {

box-shadow: 0 0 5px rgba(81, 203, 238, 1);

padding: 3px 0px 3px 3px;

margin: 5px 1px 3px 0px;

border: 1px solid rgba(81, 203, 238, 1);

}

34、強制換行

pre {

white-space: pre-wrap;

word-wrap: break-word;

}

35、在可點擊的項目上強制手型

.pointer {

cursor: pointer;

}

36、網頁頂部盒陰影

body:before {

content: "";

position: fixed;

top: -10px;

left: 0;

width: 100%;

height: 10px;

box-shadow: 0px 0px 10px rgba(0,0,0,.8);

z-index: 100;

}

37、CSS3對話氣泡

.line {

background-color: #ededed;

border: 2px solid #666;

font-size: 35px;

line-height: 1.3em;

margin: 10px auto;

padding: 10px;

position: relative;

text-align: center;

width: 300px;

border-radius: 20px;

box-shadow: 0 0 5px #888;

}

.chat-bubble-arrow-border {

border-color: #666 transparent transparent transparent;

border-style: solid;

border-width: 20px;

height: 0;

width: 0;

position: absolute;

bottom: -42px;

left: 30px;

}

.chat-bubble-arrow {

border-color: #ededed transparent transparent transparent;

border-style: solid;

border-width: 20px;

height: 0;

width: 0;

position: absolute;

bottom: -39px;

left: 30px;

}

38、持久的列表排序

ol.chapters {

list-style: none;

margin-left: 0;

}

ol.chapters > li:before {

content: counter(chapter) ". ";

counter-increment: chapter;

font-weight: bold;

float: left;

width: 40px;

}

ol.chapters li {

clear: left;

}

ol.start {

counter-reset: chapter;

}

ol.continue {

counter-reset: chapter 11;

}

39、CSS懸浮提示文本

a {

border-bottom:1px solid #bbb;

color:#666;

display:inline-block;

position:relative;

text-decoration:none;

}

a:hover,

a:focus {

color:#36c;

}

a:active {

top:1px;

}

a[data-tooltip]:after {

border-top: 8px solid #222;

border-top: 8px solid hsla(0,0%,0%,.85);

border-left: 8px solid transparent;

border-right: 8px solid transparent;

content: "";

display: none;

height: 0;

width: 0;

left: 25%;

position: absolute;

}

a[data-tooltip]:before {

background: #222;

background: hsla(0,0%,0%,.85);

color: #f6f6f6;

content: attr(data-tooltip);

display: none;

font-family: sans-serif;

font-size: 14px;

height: 32px;

left: 0;

line-height: 32px;

padding: 0 15px;

position: absolute;

text-shadow: 0 1px 1px hsla(0,0%,0%,1);

white-space: nowrap;

-webkit-border-radius: 5px;

-moz-border-radius: 5px;

-o-border-radius: 5px;

border-radius: 5px;

}

a[data-tooltip]:hover:after {

display: block;

top: -9px;

}

a[data-tooltip]:hover:before {

display: block;

top: -41px;

}

a[data-tooltip]:active:after {

top: -10px;

}

a[data-tooltip]:active:before {

top: -42px;

}

40、深灰色的圓形按鈕

.graybtn {

box-shadow:inset 0px 1px 0px 0px #ffffff;

background:gradient( linear, left top, left bottom, color-stop(0.05, #ffffff), color-stop(1, #d1d1d1) );

filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#d1d1d1');

background-color:#ffffff;

border-radius:6px;

border:1px solid #dcdcdc;

display:inline-block;

color:#777777;

font-family:arial;

font-size:15px;

font-weight:bold;

padding:6px 24px;

text-decoration:none;

text-shadow:1px 1px 0px #ffffff;

}

.graybtn:hover {

background:gradient( linear, left top, left bottom, color-stop(0.05, #d1d1d1), color-stop(1, #ffffff) );

filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d1d1d1', endColorstr='#ffffff');

background-color:#d1d1d1;

}

.graybtn:active {

position:relative;

top:1px;

}

41、顯示a連結得URLs

@media print {

a:after {

content: " [" attr(href) "] ";

}

}

42、禁用移動Webkit的選擇高亮

body {

-webkit-touch-callout: none;

-webkit-user-select: none;

-khtml-user-select: none;

-moz-user-select: none;

-ms-user-select: none;

user-select: none;

}

43、CSS3 圓點圖案

body {

background: radial-gradient(circle, white 10%, transparent 10%),

radial-gradient(circle, white 10%, black 10%) 50px 50px;

background-size: 100px 100px;

}

44、CSS3 方格圖案

body {

background-color: white;

background-image: linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black),

linear-gradient(45deg, black 25%, transparent 25%, transparent 75%, black 75%, black);

background-size: 100px 100px;

background-position: 0 0, 50px 50px;

}

45、CSS font屬性縮寫

p {

font: italic small-caps bold 1.2em/1.0em Arial, Tahoma, Helvetica;

}

46、論文頁面的捲曲效果

ul.box {

position: relative;

z-index: 1;

overflow: hidden;

list-style: none;

margin: 0;

padding: 0;

}

ul.box li {

position: relative;

float: left;

width: 250px;

height: 150px;

padding: 0;

border: 1px solid #efefef;

margin: 0 30px 30px 0;

background: #fff;

-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;

-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;

box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;

}

ul.box li:before,

ul.box li:after {

content: '';

z-index: -1;

position: absolute;

left: 10px;

bottom: 10px;

width: 70%;

max-width: 300px; /* avoid rotation causing ugly appearance at large container widths */

max-height: 100px;

height: 55%;

-webkit-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);

-moz-box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);

box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);

-webkit-transform: skew(-15deg) rotate(-6deg);

-moz-transform: skew(-15deg) rotate(-6deg);

-ms-transform: skew(-15deg) rotate(-6deg);

-o-transform: skew(-15deg) rotate(-6deg);

transform: skew(-15deg) rotate(-6deg);

}

ul.box li:after {

left: auto;

right: 10px;

-webkit-transform: skew(15deg) rotate(6deg);

-moz-transform: skew(15deg) rotate(6deg);

-ms-transform: skew(15deg) rotate(6deg);

-o-transform: skew(15deg) rotate(6deg);

transform: skew(15deg) rotate(6deg);

}

47、鮮豔的錨連結

a {

color: #00e;

}

a:visited {

color: #551a8b;

}

a:hover {

color: #06e;

}

a:focus {

outline: thin dotted;

}

a:hover, a:active {

outline: 0;

}

a, a:visited, a:active {

text-decoration: none;

color: #fff;

transition: all .3s ease-in-out;

}

a:hover, .glow {

color: #ff0;

text-shadow: 0 0 10px #ff0;

}

48、帶CSS3特色的橫幅顯示

.featureBanner {

position: relative;

margin: 20px

}

.featureBanner:before {

content: "Featured";

position: absolute;

top: 5px;

left: -8px;

padding-right: 10px;

color: #232323;

font-weight: bold;

height: 0px;

border: 15px solid #ffa200;

border-right-color: transparent;

line-height: 0px;

box-shadow: -0px 5px 5px -5px #000;

z-index: 1;

}

.featureBanner:after {

content: "";

position: absolute;

top: 35px;

left: -8px;

border: 4px solid #89540c;

border-left-color: transparent;

border-bottom-color: transparent;

}

49、限制單行文本超出顯示省略號

div{

width: 65px;

height: 30px;

line-height: 30px;

overflow: hidden;

text-overflow: ellipsis;

white-space: nowrap;

font-size: 14px;

}

50、限制多行文本超出省略號

div{

overflow : hidden;

text-overflow: ellipsis;

display: -webkit-box;

-webkit-line-clamp: 2;

-webkit-box-orient: vertical;

}

51、css三角形繪製

.sj {

width: 0;

height: 0;

border-width: 100px;

border-style: solid;

}

.sj-left {

border-color: transparent pink transparent transparent;

}

.sj-right {

border-color: transparent transparent transparent pink;

}

.sj-top {

border-color: transparent transparent pink transparent;

}

.sj-bottom {

border-color: pink transparent transparent transparent;

}

52、自適應文本框自動換行,限寬不限高

div{

display: inline-block;

min-height: 15px;

max-width: 78%;

padding: 12px 10px;

text-align: left;

font-family: Microsoft YaHei;

word-wrap: break-word;

}

53、 ~選擇器:查找某一個元素後面的所有兄弟元素

例如 .test~.name{background:red}

54、 +選擇器:查找某一個元素後面緊鄰的兄弟元素

例如 .test+.name{background:red}

55、 用 font-size :0 來清除邊距56、 利用padding實現等比例縮放的盒子

最外層容器{

display:flex;

display:flex-box;

flex-wrap:warp;

}

最外層容器 > 子元素{

flex-basis:25%;

}

最外層容器 > 子元素 > 父元素{

width:100%;

padding-top:75%;

position:relative;

}

最外層容器 > 子元素 > 父元素 > 子元素{

width:100%;

height:100%;

position:absolute;

top:0;

left:0;

}

57、利用pointer-events禁用事件光標變成default阻止hover和hover以及JavaScript 點擊事件的觸發

pointer-events:none;

58、利用 max-width 防止圖片撐破容器

img{

max-width:100%;

display:inline-block;

}

59、偽類和偽元素的用法

// 偽類是用 : 來表示,偽元素是用 :: 來表示

常見的偽類有:

:hover

:active

:focus

:visited

:link

:lang

:first-child

:last-child

:not

:nth-child

// 偽元素就是不存在DOM文檔樹中的虛擬元素,它們和HTML元素一樣,但是你又無法使用javascript去獲取

常見偽元素

::before

::after

::first-letter

::first-line

用 :valid 和 :invalid 來做表單驗證

html5 提供了類似required Email tel 等表單屬性

:required // 指定具有required屬性的表單元素

:valid // 指定一個通過匹配正確的所要求的表單元素

:invalid // 指定一個不匹配指定要求的表單元素

<input type="text" required />

input:vaild{ 如果輸入文字則變成綠色

border:1px solid green;

box-shadow:inset 10px 0 0 green;

}

input:invaild{ 如果沒有輸入則是紅色

border:1px solid red;

box-shadow:inset 10px 0 0 red;

}

用:target來實現摺疊面板

用:not來排除其他選擇器

:not([readonly]):not([.disabled]):not([text]) 等

用:nth-child 來實現各行變色

:nth-child(2n+1){background:red;}

:nth-child(2n){backgorund:blue;}

用::selection 來美化選中文本

p::selection{

background:red;

color:green;

}

用::placeholder 美化輸入框佔位符樣式

::placeholder{

color:Red;

}

用::first-letter 來實現段落首字下沉

p::first-letter{

font-size:30px;

color:Red;

padding:20px;

}

用::first-line 來標記段落的第一行

p::first-line{

color:red;

}

60、footer永遠在頁面底部

<style>

body {

position:absolute;

width:100%;

min-height:100%;

}

#app {

padding-bottom: 200px;

height: 100%;

font-family: "Microsoft Yahei", Arial, sans-serif;

-webkit-font-smoothing: antialiased;

-moz-osx-font-smoothing: grayscale;

color: #333;

min-width: 1190px;

}

</style>

footer {

clear: both;

position: absolute;

bottom: 0px;

width: 100%;

background: #000;

color: #fff;

min-width: 1200px;

height: 200px;

}

61、兩個子元素 一個有內容自動撐開,另一個為空如何跟隨高度。

.f{

display: flex;

align-items: stretch;

}

62、消除transition閃屏

.css {

transform: translate3d(0,0,0);

}

相關焦點

  • 推薦幾個大廠的前端代碼規範,你也能寫出詩一樣的代碼!
    公眾號:前端GitHub,專注於挖掘 GitHub 上優秀的前端開源項目,抹平你的前端信息不對稱,涵蓋 JavaScript、Vue、React、Node、小程序、Flutter、Deno、HTML、CSS、數據結構與算法 等等。以下為【前端GitHub】的第 5 期內容。
  • 給設計師們的代碼指南!HTML與CSS簡介(一)
    編者按:@不到布 :謹以此文獻給那些被代碼折磨的設計師們,和那些與前端無法交流的設計師們。
  • 《前端5分鐘》之使用純css實現網站換膚和焦點圖切換動畫
    本文轉載自【微信公眾號:趣談前端,ID:beautifulFront】經微信公眾號授權轉載,如需轉載與原文作者聯繫今天我們來繼續復盤一些工作中常用的css技巧和知識,以便我們可以更加優雅的用css實現富有動感的網站.
  • Python學習第233課——css中的長度單位
    很多時候,網頁上的某些元素,是需要給它設定寬度和高度的,比如一張圖片,一般情況下使需要給它給定一個具體的寬度和高度的,這樣瀏覽器在解析你的網頁代碼時,看到你代碼中設定的寬高,就會直接按你的寬高去"繪製"網頁,否則,瀏覽器就會自己去計算你這個網頁中的這個圖片的寬高,計算完才會去"繪製"網頁,這樣多了一個計算寬高的步驟,就會影響網頁的渲染(繪製)速度,作為一個開發者
  • 將CSS樣式代碼應用到HTML頁面的幾種方式
    2、內嵌樣式表內嵌樣式表是在頭部區域,利用<style></style>標籤書寫CSS樣式代碼,格式如下圖:其中,「選擇器」可以是HTML的標籤,也可是CSS的類。type=」text/css」用來定義文件的類型為樣式表文本文件。
  • 一個在線css三角形生成器
    本文轉載自【微信公眾號:趣談前端,ID:beautifulFront】經微信公眾號授權轉載,如需轉載與原文作者聯繫為了提高 前端開發效率, 筆者先後寫了上百個前端工具, 有些是給公司內部使用的, 有些單純是因為自己太「懶」, 不想寫代碼, 所以才「被迫
  • css利器之sass
    內容導讀前言:Sass為web前端開發而生,它解決了直接進行css編寫時權重難以控制,嵌套層級多導致代碼編寫不方便的問題。並且加入了變量定義,循環,判斷等類似程式語言的代碼模式。極大的提高了編寫樣式的效率。
  • Web開發者不容錯過的20段CSS代碼
    Web開發技術每年都在革新,瀏覽器已逐漸支持CSS3特性,並且網站設計師和前端開發者普遍採用這種新技術進行設計與開發。但仍然有一些開發者迷戀著一些CSS2代碼。本文將分享20段非常專業的CSS2/CSS3代碼供大家使用,你可以把它們保存在IDE裡、或者存儲在CSS文檔裡,這些代碼片段絕對會給你帶來意外的驚喜。1.
  • 前端工程化(ES6模塊化和webpack打包css,less,scss,圖片,字體...
    /m1.js'console.log(s1) // 列印輸出aaaconsole.log(s2) // 列印輸出cccconsole.log(say) // 列印輸出[Function: say]直接導入並執行代碼有時候,我們只想單純執行某個模塊的代碼,並不需要得到模塊中向外暴露的成員,此時,可以直接導入並執行模塊代碼
  • 前端——css層疊樣式表關於引入問題
    我們通常寫css代碼有三種方式進行引入:①內聯樣式表② 內部樣式表 ③外部樣式表。1、內聯樣式表就是將css的樣式寫入html標籤當中,寫入效果如下:2、內部樣式表是將「style」當成一個標籤寫在html根元素裡面,因此,作為標籤,它也是有結束標籤的
  • css布局史 - grid一統天下
    最近幾年,前端經歷了飛速發展,每隔幾個月,就有新的技術框架產生,如果你有1年多沒有接觸過它,那麼再上手的時候,你一定會對它感到陌生,似乎一不留神,自己就已經被無情拋棄了。而作為前端三劍客的css呢?似乎css3已經是很久很久的事情了,久到了我們不知道它是否還在更新,css是否還有新的技術產生。雖然各種scss,stylus,less預處理器提高了我們代碼的開發和維護,但是css依然缺少一個一擊致命,一劍封喉的技術。
  • web前端學習什麼是css盒子模型
    web前端學習什麼是css盒子模型? 在網頁中,一個元素佔有空間的大小由幾個部分構成,其中包括元素的內容(content),元素的內邊距(padding),元素的邊框(border),元素的外邊距(margin)四個部分。
  • 前端進階:css必知的幾個底層知識和技巧
    本文轉載自【微信公眾號:趣談前端,ID:beautifulFront】經微信公眾號授權轉載,如需轉載與原文作者聯繫學習方法推薦問題學習法:帶著問題去學習,有利於集中注意力,目的明確,這既是有意學習的要求,也是發現學習的必要條件
  • Web前端學習第20課,如何為HTML元素編寫CSS樣式表
    例如,下面這行代碼的作用是將 段落元素內的文字顏色設置為綠色,同時將字體大小設置為18 像素。例如,p{color:green; font-size:18px;}。在這個例子中,p 是選擇器,color 和 font-size 是屬性,green 和 18px 是屬性值。說明:請使用花括號{}來包圍聲明。
  • CSS樣式表和選擇器
    現在,html只提供數據和一些控制項,完全交給css提供各種各樣的樣式。CSS的重點知識點盒子模型、浮動、定位CSS 整體感知我們先來看一段簡單的css代碼:<!CSS代碼理論上的位置是任意的,但通常寫在<style>標籤裡。只要是<style>標籤裡的代碼,那就是css代碼,瀏覽器就是這樣來進行解析的。CSS和HTML的結合方式有3種:行內樣式:在某個特定的標籤裡採用style屬性。範圍只針對此標籤。
  • 前端框架bootstrap4.4入門教程,使用方法實例響應式布局實戰
    bootstrap4.4.1bootstrap是移動優先的前端開發框架,本身是為了更好地適應各種移動瀏覽器而設計的,所以前端代碼必須使用HTML5和css3來寫,從bootstrap4.0和JS文件,將帶有min的拷貝到你項目中對應的css和JS文件夾裡面。
  • 前端必不可少的CSS的發展史
    CSS 一般都是和 HTML 一起工作的,為 HTML 元素添加樣式,使得界面美觀,CSS 可以使用 標籤零散地添加在 HTML 文檔中,也可以全部寫入 .css 文件中,並引入文檔中。
  • 我的前端故事----優美的編輯器GitHub Atom
    Atom可以變得更美麗~~插件篇效果可在插件首頁中查看atom-beautify:這是個美化代碼的插件,幾乎支持所有主流的語言,完全可以滿足前端同學的使用。autocomplete-paths:常用IDE的同學會常常在引入圖片的時候發現只要輸入 . 或者/ 或者文件夾名稱的時候就會自動顯示出文件夾中的內容,非常的實用,強烈推薦。
  • Web前端學習第19課,簡單了解CSS層疊樣式表
    在前面的課程中大家已經學習了,HTML和XHTML中的許多常用標籤,從這節課開始學習CSS樣式表。<p><b>要設為粗體的文字</b></p>(3) 使用樣式表來設置如果你需要更多了解和學習web前端基礎知識,請參考下面的書籍。
  • Python學習第235課——html引入css的4種方式
    之前我們寫css代碼,都是在html文件的<head>標籤裡面的<style>標籤裡面,直接寫css代碼。在html中以這種方式引入css,叫做內嵌式方法。通過連結式方法,在html文件中不需要寫css代碼,只需要引入外部的css文件,就能起到跟內嵌式方法一樣的效果。