Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
<!DOCTYPE html> <html> <head> <meta name="robots" content="noindex,nofollow" /> <style> /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */ html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} html { background: #eee; padding: 10px } img { border: 0; } #sf-resetcontent { width:970px; margin:0 auto; } .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 } .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; } .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; } .sf-reset .clear_fix { display:inline-block; } .sf-reset * html .clear_fix { height:1%; } .sf-reset .clear_fix { display:block; } .sf-reset, .sf-reset .block { margin: auto } .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; } .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px } .sf-reset strong { font-weight:bold; } .sf-reset a { color:#6c6159; cursor: default; } .sf-reset a img { border:none; } .sf-reset a:hover { text-decoration:underline; } .sf-reset em { font-style:italic; } .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif } .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; } .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; } .sf-reset .exception_message { margin-left: 3em; display: block; } .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; } .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px; -webkit-border-bottom-right-radius: 16px; -webkit-border-bottom-left-radius: 16px; -moz-border-radius-bottomright: 16px; -moz-border-radius-bottomleft: 16px; border-bottom-right-radius: 16px; border-bottom-left-radius: 16px; border-bottom:1px solid #ccc; border-right:1px solid #ccc; border-left:1px solid #ccc; } .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px; -webkit-border-top-left-radius: 16px; -webkit-border-top-right-radius: 16px; -moz-border-radius-topleft: 16px; -moz-border-radius-topright: 16px; border-top-left-radius: 16px; border-top-right-radius: 16px; border-top:1px solid #ccc; border-right:1px solid #ccc; border-left:1px solid #ccc; overflow: hidden; word-wrap: break-word; } .sf-reset a { background:none; color:#868686; text-decoration:none; } .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; } .sf-reset ol { padding: 10px 0; } .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px; -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; border: 1px solid #ccc; } </style> </head> <body> <div id="sf-resetcontent" class="sf-reset"> <h1>Whoops, looks like something went wrong.</h1> </div> </body> </html>
海無涯,不要沉浸在知識(shí)的海洋里,迷失自己。
要知道自己想要什么,抓住重點(diǎn),不忘初心。
這個(gè)世界上百分之20的人,掌握著百分之80的財(cái)富。
接下來一系列教程,就帶領(lǐng)大家抓住重點(diǎn),一起做那百分之20的人。
往期知識(shí)點(diǎn)回顧:
重點(diǎn)屬性-display
重點(diǎn)屬性-position
重點(diǎn)屬性-float
重點(diǎn)屬性-flex
重點(diǎn)屬性-overflow
重點(diǎn)屬性-media
CSS 背景這里指通過background對(duì)對(duì)象設(shè)置背景屬性,如通過CSS設(shè)置背景各種樣式。
設(shè)置顏色作為對(duì)象背景顏色
設(shè)置圖片作為背景圖片
設(shè)置背景平鋪重復(fù)方向
設(shè)置或檢索背景圖像是隨對(duì)象內(nèi)容滾動(dòng)還是固定的。
設(shè)置或檢索對(duì)象的背景圖像位置。
背景樣式的值是復(fù)合屬性值組合,也就是背景單詞的值可以跟多個(gè)屬性值,值與值之間使用一個(gè)空格間隔鏈接上即可。
1、設(shè)置純色背景。背景background可以設(shè)置對(duì)象純色的背景顏色,
2、設(shè)置圖為背景。可以設(shè)置對(duì)象背景為圖片,如果背景是圖片可以讓圖片重復(fù)平鋪橫鋪,或?qū)D片作為對(duì)象背景固定在對(duì)象任何位置。
屬性解析
no-repeat:不重復(fù)
repeat-x:水平方向(橫向)重復(fù)平鋪
repeat-y:垂直方向(豎向)重復(fù)平鋪
如果不設(shè)置,為全背景平鋪
left 圖片靠左
right 圖片靠右
top 圖片靠上
bottom 圖片靠下
fixed 圖片固定
scroll 背景圖片內(nèi)容滾動(dòng)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>flex布局css</title>
<style>
.container{
background: #FFF url(https://image.baidu.com/beijing.gif) no-repeat 0 0 fixed
}
</style>
</head>
<body>
<div class="container">
背景圖
</div>
</body>
</html>
復(fù)制代碼
1、由使用float浮動(dòng)造成浮動(dòng)產(chǎn)生無法顯示css背景顏色
2、高度不夠而產(chǎn)生背景無法顯示
3.如果是float造成:解決方法有三種,一個(gè)是設(shè)置clear清除浮動(dòng)、設(shè)置css高度、設(shè)置css overflow樣式。
4.如果是高度原因:解決方案如下,設(shè)置夠高的高度,或取消刪除高度樣式即可。
目前PC網(wǎng)站大多使用float布局,從成本上考慮大改的概率很小,所以不要說浮動(dòng)無用,總是會(huì)有機(jī)會(huì)讓你維護(hù)的!代表網(wǎng)站:淘寶、騰訊、百度,好吧BAT都到齊了。
浮動(dòng)聽得多了,博客園上關(guān)于用浮動(dòng)布局的介紹也非常的多。浮動(dòng)原本用于文本環(huán)繞,但卻在布局被發(fā)揚(yáng)光大,這就是命!我的理解:浮動(dòng)布局的核心就是讓元素脫離普通流,然后使用width/height,margin/padding將元素定位。脫離普通流的元素,就像脫離地心引力一樣,與普通流不在一個(gè)高度上。這個(gè)跟圖層的概念類似。高度不同所以可以疊在其他元素上面產(chǎn)生重疊或者使用負(fù)邊距跑到父元素外,理解了這一點(diǎn)浮動(dòng)布局就很好理解了。
下面用個(gè)圣杯布局的例子說明一下,理解了這個(gè)之后其他布局更加簡單:
left,寬度固定,高度可固定也可由內(nèi)容撐開
right,寬度固定,高度可固定也可由內(nèi)容撐開
center,可以自適應(yīng)瀏覽器寬度,高度可固定也可由內(nèi)容撐開。
原理非常簡單,左右側(cè)邊欄定寬并浮動(dòng),中部內(nèi)容區(qū)放最后不浮動(dòng)、默認(rèn)width:auto并設(shè)置相應(yīng)外邊距,讓左右側(cè)邊欄浮動(dòng)到上面。注意:子元素設(shè)置為浮動(dòng)之后,父對(duì)象的高度就坍塌了,需要設(shè)置父對(duì)象后的元素清除浮動(dòng),這樣父對(duì)象的高度才能被浮動(dòng)子元素?fù)纹饋砹恕?/p>
當(dāng)然,我們也要問一下,為啥父對(duì)象高度會(huì)坍塌呢?上面也說過了,浮動(dòng)元素已經(jīng)脫離了普通流,父對(duì)象所在的普通流比喻成地表,那浮動(dòng)元素就已經(jīng)上天了。但是父對(duì)象還在地表啊,從外太空看浮動(dòng)元素在父對(duì)象里面,但是其實(shí)并不在,又怎么能撐開父對(duì)象呢?寬度如果我們不設(shè)置的話,其實(shí)也是為0的,因?yàn)楦笇?duì)象里面空空如也,所以寬高為0。要撐開的辦法就兩個(gè):
辦法1:是讓父對(duì)象也上天 2是把浮動(dòng)元素的邊框邊界拉下來。父對(duì)象也上天(即浮動(dòng))的話,那就不能實(shí)現(xiàn)寬度自適應(yīng)了。因?yàn)閒loat元素的width:auto是包裹內(nèi)容的,參考前面說的!
辦法2:就是在后面的元素里加一個(gè)clear語句。說到這個(gè)問題就要扯到clear與BFC了,我就不獻(xiàn)丑了。傳送門:https://developer.mozilla.org/zh-CN/docs/Web/CSS/clear
這個(gè)三列布局還有個(gè)雙飛翼的變種,就是在HTML中center部分也就是內(nèi)容區(qū)提到最前面,也就是內(nèi)容先行渲染。在網(wǎng)絡(luò)不好的時(shí)候,左右雙翼能不能出來不要緊,先讓主體內(nèi)容出來!這種想法是優(yōu)秀工程師思維
思路:
1)既然HTML里面要讓center放前面,為了讓left跑到center前面,那center也必須浮動(dòng)了,否則因?yàn)槎际菈K元素他們會(huì)分兩行。
2)浮動(dòng)之后還要讓center寬度自適應(yīng),那明顯width只能100%,然后在父元素中設(shè)width:auto,還有兩側(cè)margin,其實(shí)也就是父對(duì)象寬度自適應(yīng),center只是繼承content的寬度。
3)對(duì)left使用負(fù)的margin讓他們浮動(dòng)到上方去。
代碼里面我用到了一個(gè)calc(),這個(gè)CSS3帶來的計(jì)算函數(shù)簡直酷斃了!本例里如果不使用calc函數(shù),那么就需要wrap左邊距為0,left左邊距-100%,然后center多加一層子塊DIV設(shè)置margin-left:100px,可以達(dá)到同樣的效果!calc函數(shù)與百分比配合就足以實(shí)現(xiàn)自適應(yīng)的要求!目前所有的自適應(yīng)布局都在利用瀏覽器來為我們計(jì)算尺寸,但是有了calc之后我們就可以自己制定規(guī)則!
使用浮動(dòng)來進(jìn)行布局,一個(gè)比較大的問題是清除浮動(dòng)。這個(gè)可以使用一個(gè)after偽類來清除。更大的問題是浮動(dòng)性像水一樣向上流動(dòng),難以把握。在元素較多而且元素高度尺寸不一的情況下,單純使用浮動(dòng)只能實(shí)現(xiàn)上端對(duì)齊,這對(duì)于適應(yīng)多種設(shè)備的布局就顯得力不從心了。目前的做法是犧牲一部分內(nèi)容,將元素做成等高排列,從美觀上看也當(dāng)然也是極好的,比參差不齊的排列要美觀。
參考位置:https://blog.csdn.net/three_bird/article/details/51468817?utm_source=blogxgwz11
版權(quán)聲明:如有侵權(quán),請(qǐng)聯(lián)系刪除
*請(qǐng)認(rèn)真填寫需求信息,我們會(huì)在24小時(shí)內(nèi)與您取得聯(lián)系。