css div撐滿窗口高度_如何使用CSS將div的高度設置為窗口的100%?

css div撐滿窗口高度

Introduction:

介紹:

Hello there developers! Well, certainly if you are reading this article then that means that you have run into some trouble while creating your web page or website and if you are a beginner in this field, then there is no better place than this. So let us get started without further adieu. But before we can proceed forward with this article it is crucial to know that what are divs and what could be their possible uses.

您好,開發人員! 好吧,當然,如果您正在閱讀本文,那么這意味著您在創建網頁或網站時遇到了麻煩,并且如果您是該領域的初學者,那么沒有比這更好的地方了。 因此,讓我們開始吧! 但是在繼續本文之前,至關重要的是要知道什么是div以及它們的可能用途。

Definition and uses:

定義和用途:

Well, divs are something that we deal with regularly while developing a web page or website, the divs are used to group lines of texts or elements and anything similar, besides divs are also used to structure the code, so that various sections remain segregated from each other. Although you can make use of section tag both of them behave pretty similarly. Besides divs also help in declaring class and ids of the various elements. Therefore, in a nutshell, it would be right to say that divs are very essential when we are developing a website or web page and divs also help in keeping our code structured.

好吧,divs是我們在開發網頁或網站時經常處理的事情,divs用于對文本或元素行以及類似內容進行分組,此外divs還用于構造代碼,以便各個部分與彼此。 盡管您可以使用section標簽,但它們的行為都非常相似。 除了div之外,還有助于聲明各種元素的類和ID。 因此,總的來說,當我們開發網站或網頁時,div是非常重要的,而div也有助于保持代碼的結構化。

Solution:

解:

We have already seen by now how to set the height of the div elements using CSS height property? Now the question arises what if we want to set the height of the div 100% height of the window? here comes the answer to the solution that is using the vh property in CSS. We will discuss the vh property in detail in this article.

到目前為止,我們已經看到了如何使用CSS height屬性設置div元素的高度? 現在出現了一個問題,如果我們想將div的高度設置為窗口高度的100%,該怎么辦? 這是使用CSS中的vh屬性的解決方案的答案。 我們將在本文中詳細討論vh屬性。

Property:

屬性:

Here, "vh" stands for "viewport-height", and the word viewport refers to the user's browser windows size. So whenever we use the vh property, the element's height is adjusted relative to the height of the viewport.

在此, “ vh”代表“ viewport-height” ,而“ viewport”一詞指的是用戶瀏覽器窗口的大小。 因此,每當我們使用vh屬性時 ,元素的高度都會相對于視口的高度進行調整。

To set the height of div element to 100% height of the window, we can use the following syntax,

要將div元素的高度設置為窗口的100%高度 ,我們可以使用以下語法,

Syntax:

句法:

    element{
height:100vh;
}

Example:

例:


Output

輸出量

How to Set height of div to 100% height of window using CSS?

In the above example, it can be seen that by making use of the viewport-height property the height of the div element is 100% height of the window. Therefore, now you know both how to increase the height of the element as well as how to make it equivalent to 100% height of the window.

在上面的示例中,可以看到,通過使用viewport-height屬性,div元素的高度為window的100%高度 。 因此,現在您知道如何增加元素的高度以及如何使其等于窗口的100%高度。

This method proves to be very helpful, so just keep in mind that all you gotta do is make use of "vh" property and there you got it!

這種方法被證明是非常有用的,因此請記住,您要做的就是利用“ vh”屬性 ,您就已經掌握了!

翻譯自: https://www.includehelp.com/code-snippets/how-to-set-height-of-div-to-100-percentage-height-of-window-using-css.aspx

css div撐滿窗口高度

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542781.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542781.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542781.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

.net core image怎么保存_輕量級Vue圖片上傳插件——Vue-core-image-Upload

介紹vue-core-image-upload 是一款輕量級的 Vue.js 上傳插件,它可以支持的圖片的上傳,裁剪,壓縮。它同樣也支持在移動端的圖片處理,它定義了諸多上傳周期,你可以自由的進行流程控制。Githubhttps://github.com/Vanthin…

mysql確認半同步命令_怎么判斷mysql是否是半同步復制

AFTER_COMMIT(5.6默認值)master將每個事務寫入binlog ,傳遞到slave 刷新到磁盤(relay log),同時主庫提交事務。master等待slave 反饋收到relay log,只有收到ACK后master才將commit OK結果反饋給客戶端。AFTER_SYNC(5.7默認值,但5.6中無此模式…

stl iterator_在C ++ STL中使用const_iterator訪問字符列表的元素

stl iteratorIn this example, we are declaring a character list and pushing the characters from A to Z using a for loop and push_back() function and then accessing the elements using const_iterator. 在此示例中,我們聲明一個字符列表,并使…

《Linus Torvalds自傳》摘錄

轉自:http://www.ruanyifeng.com/blog/2012/09/linus_torvalds.html作者: 阮一峰日期: 2012年9月 3日除了程序員,大概很少人知道Linux操作系統。它的發明者Linus Torvalds,知道的人就更少了。他本人也很低調&#xff0…

python繪制條形圖例題_python matplotlib庫繪制條形圖練習題

練習一:假設你獲取到了2017年內地電影票房前20的電影(列表a)和電影票房數據(列表b),那么如何更加直觀的展示該數據? a ["戰狼2","速度與激情8","功夫瑜伽",&quo…

mysql驗證身份證號正確_通過SQL校驗身份證號碼是否正確

根據提供的身份證號碼信息驗證身份證號碼是否符合二代身份證規范,其中區域編碼網上可下載。使用數據庫為DB2,但目測可以通用身份證號碼第18位驗證算法從網上查得,具體驗證算法如下:1、將前面的身份證號碼17位數分別乘以不同的系數…

python學習記錄

python學習記錄schedule庫schedule庫 import schedule import time #引入schedule和timedef job():print("Working in progress...") #定義一個叫job的函數,函數的功能是打印Im working...#部署情況 schedule.every(10).minutes.do(job) #部署每10…

Python | 在屬性的幫助下實現setter和getter

In this program, we are implementing Properties. Python offers a better way to implement setters and getter with the help of properties by using attribute property. By default properties are getters so we have to declare setter part explicitly. 在此程序中&…

windows進入mysql

cd \wamp\bin\mysql\mysql5.6.17\bin\mysql -hlocalhost -uroot -p轉載于:https://blog.51cto.com/8818968/1835449

python爬取js動態網頁_Python 爬取網頁中JavaScript動態添加的內容(一)

當我們進行網頁爬蟲時,我們會利用一定的規則從返回的 HTML 數據中提取出有效的信息。但是如果網頁中含有 JavaScript 代碼,我們必須經過渲染處理才能獲得原始數據。此時,如果我們仍采用常規方法從中抓取數據,那么我們將一無所獲。…

mac mysql 忘記密碼 卸載_MySQL忘記密碼后重置密碼(Mac )

轉:http://www.cnblogs.com/lihuanqing/p/5623872.html安裝好MySQL以后,系統給了個默認的的密碼,然后不小心關了,慘了密碼沒有了。1、關閉mysql服務器 sudo /usr/local/mysql/support-files/mysql.server stop 也可以在系統偏好里…

MATLAB學習——變量、數組

變量、數組變量賦值顯示格式數組一維數組生成數組元素提取提取單個元素抽取二維數組生成數組提取提取單個元素提取子矩陣添加字符數組空數組變量 賦值 賦值語句一般形式:變量 數、字符或表達式 a 1 #自定義為雙精度double x x y 1*2*3顯示格式 可以…

Nginx嚴格訪問代理HTTP資源

為什么80%的碼農都做不了架構師?>>> 1 嚴格訪問 訪問能基于客戶端的IP地址允許或拒絕或使用基于HTTP驗證。 為了允許或拒絕從某個地址及或所有地址的訪問,使用allow和deny指令: location / { deny 192.168.1.2; allow 192.168…

Java LinkedList公共布爾boolean offerLast(Object o)方法(帶示例)

LinkedList公共布爾布爾offerLast(Object o)方法 (LinkedList public boolean offerLast(Object o) method) This method is available in package java.util.LinkedList.offerLast(Object o). 軟件包java.util.LinkedList.offerLast(Object o)中提供了此方法。 This method is…

csv 字符串_Python實現json轉csv格式

利用Python實現json格式轉換為csv文件格式前言本文是學校的課程設計,這里我沒有用封裝好的json庫來實現,而是把讀進來的文件當一個字符串來處理,核心函數其實是python的eval()類型轉換函數。什么是 JSON?我們要考慮到json格式下key-value對的…

MATLAB學習——常用語句

MATLAB學習——常用語句if語句if endif elseif elseifswitch語句for語句while語句if語句 if end n input(n); if rem(n,2) 0A even endif else n input(n); #輸入空數組判斷為odd if rem(n,2) 0A even elseA odd endif elseif n input(n); if rem(n,2) 0;even els…

mysql 線性表_數據結構之線性表

概要參考《大話數據結構》,把常用的基本數據結構梳理一下。線性表定義線性表(List):零個或多個數據元素的有限序列。若將線性表記為 \((a_1, \cdots, a_{i-1}, a_i, a_{i1}, \cdots, a_n)\),則表中 \(a_{i-1}\) 領先于 \(a_i\),\(…

使用JavaScript修改瀏覽器URL地址欄的實現代碼

現在的瀏覽器里,有一個十分有趣的功能,你可以在不刷新頁面的情況下修改瀏覽器URL;在瀏覽過程中.你可以將瀏覽歷史儲存起來,當你在瀏覽器點擊后退按鈕的時候,你可以沖瀏覽歷史上獲得回退的信息,這聽起來并不復雜,是可以…

ruby array_在Ruby中使用Array.pop和Array.shift方法從Array中刪除元素

ruby arrayRuby Array.pop和Array.shift方法 (Ruby Array.pop and Array.shift methods) If you are reading an article that is related to deleting elements from the instance of Array class then it is expected from you that you are aware of the basic things relat…

python語言百分號的含義_python中百分號意思的是什么

python中百分號意思的是什么 發布時間:2020-07-09 16:38:13 來源:億速云 閱讀:158 python中百分號意思的是什么?很多新手對此不是很清楚,為了幫助大家解決這個難題,下面小編將為大家詳細講解,有…