css 隐藏元素 显示元素_使用CSS打印时如何隐藏元素?
css 隱藏元素 顯示元素
Introduction:
介紹:
We have come across many challenges while developing a website or web page and every challenge comes with new learnings. It is a trait of a good developer who develops or creates websites or web pages by learning at the same time. Therefore, every challenge posed at you, you must not give in there are numerous sources on the internet from where you can look for answers and get your problem solved. Besides, such problems come with an opportunity to learn something which in turn would improve your knowledge and you will be able to master skills to a greater extent. Similarly, the topic here is How to hide elements at the time of printing. Well, it sounds a bit tricky but the solution is very easy, so read on to find the answer.
在開發網站或網頁時,我們遇到了許多挑戰,每個挑戰都伴隨著新的學習。 這是一個優秀的開發人員的特征,他通過同時學習來開發或創建網站或網頁。 因此,面對您的每項挑戰,您都不能放棄互聯網上的大量資源,您可以從中尋找答案并解決問題。 此外,這些問題還提供了學習一些東西的機會,這些東西反過來會提高您的知識,并且您將能夠更大程度地掌握技能。 同樣,此處的主題是如何在打印時隱藏元素。 好吧,這聽起來有些棘手,但是解決方案非常簡單,因此請繼續閱讀以找到答案。
Methods:
方法:
We use various ways to make our website or web page responsive. Many properties come into play for making our website or web page responsive. Well, one can not know about all the properties regarding web development but one can learn about many properties regarding web development. Therefore, with that notion in mind let us move forward with the topic which is that how can we hide the element while printing and you will be rather surprised when you find out the answer?
我們使用各種方法使我們的網站或網頁具有響應能力。 許多屬性都可以使我們的網站或網頁具有響應能力。 好吧,人們可能不知道有關Web開發的所有屬性,但是可以了解有關Web開發的許多屬性。 因此,考慮到這一概念,讓我們繼續討論這個主題,那就是我們如何在打印時隱藏元素,當您找到答案時,您會感到很驚訝嗎?
Solution:
解:
When the user wants to hide any element while printing he/she can simply use the visibility property in CSS and set its value to hidden within the @media print query. Easy as sugar right? Well, some things do sound a bit tricky at the start but when you start engaging with the problem the solution comes out to be rather easy. The method above is also easy when it comes to implementation.
當用戶想要在打印時隱藏任何元素時,他/她可以簡單地使用CSS中的visible屬性,并將其值設置為@media打印查詢中的hidden。 像糖一樣容易嗎? 好吧,開始時有些事情確實有些棘手,但是當您開始解決問題時,解決方案就會變得非常簡單。 上面的方法在實現時也很容易。
Let's make it clear with the syntax below,
讓我們用下面的語法來闡明一下,
Syntax:
句法:
@media print {element {visibility: hidden;} }Example:
例:
<!DOCTYPE html><html><head><style>@media print {img {visibility: hidden;}}</style> </head><body><h1>Hide element at print</h1><img src="img_forest.jpg" width="240" height="184"> </body></html>Output
輸出量
In the above example, initially, the page looks like this before printing the page but as soon as we print the element the output would be different.
在上面的示例中,最初,頁面在打印頁面之前看起來像這樣,但是一旦我們打印元素,輸出就會不同。
Output
輸出量
Conclusion:
結論:
So, go on and start playing around with the new-found knowledge visibility property is a very crucial property when it comes to dealing with various elements and it also helps in making a website or webpage very responsive and stylish.
因此,繼續使用新發現的知識可見性屬性是一個非常關鍵的屬性,它涉及到各種元素,并且還有助于使網站或網頁具有快速響應性和時尚性。
翻譯自: https://www.includehelp.com/code-snippets/how-to-hide-element-at-the-time-of-printing-using-css.aspx
css 隱藏元素 顯示元素
總結
以上是生活随笔為你收集整理的css 隐藏元素 显示元素_使用CSS打印时如何隐藏元素?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: stl string 函数_使用C ++
- 下一篇: 在Java中使用Collator和S