Home>Article>Web Front-end> How to set div size with css

How to set div size with css

醉折花枝作酒筹
醉折花枝作酒筹 Original
2021-04-20 16:59:13 5135browse

In CSS, you can use the width attribute and height attribute to set the div size. You only need to set the "width: value" and "height: value" styles for the div element. The width attribute defines the width of the element's content area, and the height attribute defines the height of the element's content area.

How to set div size with css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Create a new html file and name it test.html. In the test.html file, use the div tag to create a module and add text content in the div.

In the test.html file, Set the class attribute of the div tag to erliu, which is mainly used to set the css style of the div through this css.

In the test.html file, write thetag, and the css style of the page will be written in this tag.

In the css tag, write the style of the div and use the background attribute to set the background color of the div to red.

    document  
测试

View:

How to set div size with css

##In the css tag, write the style of the div, use the width attribute to set the width of the div to 200px, and use the height attribute to set the div's width The height is 100px.

.erliu{ /* width: 200px; height: 100px; */ background: red; }

View the effect:


How to set div size with css

Recommended learning:

css video tutorial

The above is the detailed content of How to set div size with css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn