Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set div height to 30px in CSS

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to set div height to 30px in CSS". The explanation in this article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to set div height to 30px in CSS".

.height (value)

Description: sets the height value of each matching element.

Added version: 1.0.height (value)

Value

Type: String, Number

A positive integer represents the number of pixels, or an integer and an optional additional unit (default: "px") (as a string).

Added version: 1.4.1.height (function (index, height))

Function (index, height)

Type: Function ()

Returns a function used to set the height. This function takes two arguments, the index parameter represents the position of the element in the collection, and the height parameter represents the original height. In this function, this points to the current element in the collection of elements.

When the .height (value) method is called, the "value" parameter can be a string (numbers plus units) or a number. If this "value" parameter provides only one number, jQuery automatically adds the unit px. If only one string is provided, any valid CSS size can assign a value to the height (such as 100px, 50%, or auto). Note that in modern browsers, the CSS height property does not contain padding, border, or margin.

If no explicit unit is given (such as' em''or'%'), then "px" is added directly by default (also understood as "px" is the default unit).

Note that the container width set by .height ('value') is based on the CSS box-sizing property. Changing the value of this property to border-box will cause this function to change the container's outerHeight instead of the original content height.

Example:

When you click on each div, set the height of the div to 30px and change the color.

Div {width:50px; height:70px; float:left; margin:5px

Background:rgb (255, 140J. 0); cursor:pointer;}

$("div") .one ('click', function () {

$(this) .height (30)

.css ({cursor: "auto", backgroundColor: "green"})

})

Thank you for reading, the above is the content of "how to set div height to 30px in CSS". After the study of this article, I believe you have a deeper understanding of how to set div height to 30px in CSS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report