How to switch the display mode of css elements

王林
Release: 2020-04-25 09:13:12
forward
2178 people have browsed it

How to switch the display mode of css elements

Conversion is achieved by setting the display attribute of the element

display value: inline (inline), block (block level), inline-block (inline block level)

(Video tutorial recommendation: css video tutorial)

The following example is to convert the display mode of span to block level and the display attribute of div to inline block level , convert the display mode of img to block level

<style>
        /*将span转换为块级元素--*/
        *{
            margin: 0;
            padding: 0;
        }
        span{
            display: block;
            background-color: red;
            width: 400px;
            height: 400px;
        }
        /*将div转换为行内块级元素*/
        div{
            display: inline-block;
            background-color: green;
            width: 300px;
            height: 300px;
        }
        /*将img转换为块级元素*/
        img{
            display: block;
            width: 200px;
        }
    </style>
Copy after login

The rendering is as follows:

How to switch the display mode of css elements

Recommended tutorial: css quick start

The above is the detailed content of How to switch the display mode of css elements. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!