Home > Web Front-end > Front-end Q&A > How to change row elements to block elements in css

How to change row elements to block elements in css

青灯夜游
Release: 2023-01-07 11:47:13
Original
4881 people have browsed it

In CSS, you can use the display attribute to convert row elements into block elements. This attribute is used to specify the type of box that the element should generate. You only need to add the "display:block;" style to the row element. Can be changed to a block element.

How to change row elements to block elements in css

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

Row elements cannot be sized, such as span

Only block elements can be sized, such as div

How to change row elements to block elements in css

nbsp;html>



    <meta>
    <meta>
    <!-- <link rel="stylesheet" href="style.css">    -->
    <style>
       div {
           width: 100px;
           height: 100px;
           background-color: pink;
       }

        a {
           width: 100px;
           height: 100px;
           background-color: pink;
       }
    </style>



    <div>块元素</div>
    <a>行元素</a>


Copy after login

How to change row elements to block elements in css

So convert row elements into block elements?

In CSS, row elements can be converted into block elements through display: block

How to change row elements to block elements in css

nbsp;html>



    <meta>
    <meta>
    <!-- <link rel="stylesheet" href="style.css">    -->
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: pink;
        }

        a {
            width: 100px;
            height: 100px;
            background-color: pink;
            display: block
        }
    </style>



    <div>块元素</div>
    <a>行元素</a>


Copy after login

How to change row elements to block elements in css

Recommended learning: CSS video tutorial

The above is the detailed content of How to change row elements to block elements in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template