img
標籤html-插入圖片路徑:絕對路徑 or 相對路徑
圖片寬高
直接給予匯入圖片的寬高值,有變形的風險
分別相較於父元素寬高的百分比
如果使用百分比的width,而沒有給予height,瀏覽器會固定將圖片寬高比例,避免變形的風險
用css加上邊框樣式
<body>
<div class="box1">box1</div>
</body>
background-color: antiquewhite;
width:1000px;
height:600px;
background-image: url("https://images.unsplash.com/photo-1553451193-d4d44c036555?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1352&q=80");
background-size:500px 333px;
background-repeat: no-repeat;
定義圖片會不會跟著瀏覽器跑動
可以將背景圖視為下層,透過background-attachment
屬性的定義,可以定義下層的背景圖是否要跟著上層的瀏覽的畫面連動位移
background-attachment:scroll
不論上層的瀏覽頁面如何捲動,其下方的背景圖會牢牢地跟著上下滑動,所以可視的圖片內容都一樣,不會改變
background-attachment:fixed
下層的背景圖片會固定在某個位置,當上層的瀏覽頁面捲動,所視畫面會隨位置的不同而看到不同的圖片內容。甚至,當下層的背景圖片不夠長,即看不到圖片了
定義圖片的位置
background-position
屬性是用來指定背景圖案的位置。
語法:
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing