url是在 Linux 終端中下載文件的絕佳工具。
下載與原始文件同名的文件的常用語法非常簡單:
curl -O URL_of_the_file
這在大多數情況下都有效,但是,您會注意到,有時當您從 GitHub 或 SourceForge 下載文件時,它不會獲取正確的文件。
例如,我試圖以 tar gz 格式下載 archinstall 腳本。這些文件位于發布頁面上。
如果我在瀏覽器中打開這個源代碼鏈接,它會得到 .tar.gz 格式的源代碼。
但是,如果我使用終端使用 curl 命令下載相同的文件,我會得到一個不正確存檔格式的小文件。
tar -zxvf v2.4.2.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
當我運行 file 命令以了解確切的文件類型時,它告訴我它是一個 HTML 文檔。
file v2.4.2.tar.gz
v2.4.2.tar.gz: HTML document, ASCII text, with no line terminators
HTML 文檔而不是存檔 zip 或 tarball?問題出在哪里?讓我告訴你快速修復。
這里的問題是您擁有的 URL 重定向到實際的存檔文件。為此,您需要使用其他選項。
curl -JLO URL_of_the_file
選項可以按任何順序排列。
這是基于 curl 命令手冊頁的選項的快速說明。
正如您在下面的屏幕截圖中所見,這次我能夠使用 curl -JLO 選項下載正確的文件。
這適用于公共文件,但是,如果您嘗試從私有存儲庫或 GitLab 下載文件,那么您可能會看到有關重定向到登錄頁面的消息。
<html><body>You are being <a href="https://gitlab.com/users/sign_in">redirected</a>.</body></html>
在這種情況下,請為 API 令牌提供 -H 選項。
首先給圖片添加一個div,設置其寬高及基本屬性,其次把div中的display元素設置成flex,最后給img添加align-items:center屬性,代碼如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style tpye="text/css">
body{
background:#000
}
div{
width: 900px;
height: 800px;
background:deeppink;
display: flex;
align-items: center;
}
div img{
width: 579px;
height: 282px;
align-items: center;
}
</style>
</head>
<body>
<div>
<img src="html.png" alt="">
</div>
</body>
</html>
看下效果
首先創建一個div,以及對有圖片的div設置樣式,給img的父級添加一個diaplay,并且屬性為table,并且把包含圖片的div中的display屬性設置成table-cell,最后給有圖片的div設置成vertical-align: middle; 屬性,代碼如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style tpye="text/css">
body{
background: #bbb;
}
div{
display: table;
width: 900px;
height: 700px;
background: #f3f3f3;
display: table-cell;
vertical-align: middle;
}
div img{
width: 282px;
}
</style>
</head>
<body>
<div>
<img src="html.png" alt="">
</div>
</body>
</html>
效果圖:
小節基本要求:
要點:
css選擇器之類選擇器
https://ypt.ink/blog/index
https://ypt.ink/blog/index
注意:更加精確一點來說, 以 . 開頭的選擇器,例如這個 .gongao樣式選擇器,統稱為類選擇器。因為它在div中引入的方式是這樣的
<div class="gonggao"></div>
class翻譯有類的意思,所有叫它類選擇器,也就是說,樣式的引入方式決定了它的稱呼。
(還是在body.css文件中寫)
.main-left .gonggao{
height: 40px;
line-height: 40px;
width: 100%;
position: relative;
border-color: #eee;
margin: 0px 0 13px;
box-shadow: -1px 0 0 rgba(0,0,0,0.04),0 -1px 0 rgba(0,0,0,0.04),1px 0 0 rgba(0,0,0,0.04);
background: #fff;
border-radius: 2px;
border-bottom-left-radius: 2px;
border-bottom-left-radius: 2px;
}
來看幾處決定性的代碼:(其它的是細節不關注)
heigth:40px; 設置框高為40px
width:100%; 設置框寬為100%
line-height: 40px; 設置框內行與行之間的間距:這值一般與height的值一樣。
background: #fff; 設置框的背景為白色
運行,直接看效果,如下:
.main-left .panel{
position: relative;
border-width: 1px;
border-style: solid;
border-radius: 2px;
box-shadow: 1px 1px 4px rgb(0 0 0 / 8%);
background-color: #fff;
color: #666;
}
.panel .guangao{
padding: 50px 30px;
}
從上節的代碼結構知道,.guanggao選擇器是在.panel里面的,也就是說我給廣告位外面加了一層框,修飾這個框的類選擇器是 .panel
看起決定性的幾處代碼,
.panel類選擇器中的:
background-color: #fff; 框的背景顏色是白色
.guanggao類選擇器中的:
padding: 50px 30px; 邊框里的內容被限制為:距離上下邊框間距是50px,左右邊框是30px;
ps:內邊距我前面是講過的。
直接看效果:
.main-left .content .card{
border-radius: 2px;
background-color: #fff;
box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);
width: 452px;
float: left;
}
從上篇文章可以知道,熱門文章與最新文章都是包含在card這個類選擇器中的,所以直接定義card的代碼。
看起決定性的代碼:
background-color: #fff; 框的背景顏色設置為白色
width: 452px; 寬度
float:left; 左浮動;
ps:左浮動我前面已經說了,代碼很關鍵。大致作用就是使得邊框朝左邊靠攏
從上篇文章知道,熱門文章與最新文章都用了card選擇器定義的div做外框,那么看效果:
左邊一個card定義的div框,右邊一個card定義的div框。分別用來盛放熱門文章與最新文章。
.card-body{
position: relative;
padding: 10px 15px;
line-height: 24px;
}
card-body類選擇器也是公用的。
定義.hot類選擇器與.new選擇器
.hot,.new{
position: relative;
height: 42px;
line-height: 42px;
padding: 0 15px;
border-bottom: 1px solid #f6f6f6;
color: #333;
border-radius: 2px 2px 0 0;
font-size: 14px;
}
運行看效果:
.tbody{
background-color: rgba(61,176,203,0.15);
padding: 10px;
overflow: hidden;
}
.tbody .is-main{
width: 85%;
margin: 0 auto;
}
.is-main .main-left{
width: 71%;
float: left;
}
.is-main .main-right{
width: 28%;
float: right;
}
.main-left .gonggao{
height: 40px;
line-height: 40px;
width: 100%;
position: relative;
border-color: #eee;
margin: 0px 0 13px;
box-shadow: -1px 0 0 rgba(0,0,0,0.04),0 -1px 0 rgba(0,0,0,0.04),1px 0 0 rgba(0,0,0,0.04);
background: #fff;
border-radius: 2px;
border-bottom-left-radius: 2px;
border-bottom-left-radius: 2px;
}
.main-left .panel{
position: relative;
border-width: 1px;
border-style: solid;
border-radius: 2px;
box-shadow: 1px 1px 4px rgb(0 0 0 / 8%);
background-color: #fff;
color: #666;
}
.panel .guangao{
padding: 50px 30px;
}
.main-left .content .card{
border-radius: 2px;
background-color: #fff;
box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);
width: 452px;
float: left;
}
.card-body{
position: relative;
padding: 10px 15px;
line-height: 24px;
}
.hot,.new{
position: relative;
height: 42px;
line-height: 42px;
padding: 0 15px;
border-bottom: 1px solid #f6f6f6;
color: #333;
border-radius: 2px 2px 0 0;
font-size: 14px;
}
建議對照body.html文件看,那樣會更清晰。可以多試試代碼,怎么試?
刪一行代碼運行一下,看看效果是什么樣,加上去又是一個什么樣,這樣學很快就明白了。
*請認真填寫需求信息,我們會在24小時內與您取得聯系。