current position:Home>HTML Li set margin: 50%, but the width of the outermost div is the standard

HTML Li set margin: 50%, but the width of the outermost div is the standard

2022-04-29 06:58:25CSDN Q & A

by li Added a margin:50%, But the outer margin is the outermost layer div Of ,ul Width and height are also set , I am here ul And outermost layer div Another one is added in the room div Set the width and height , however li The outer margin is still the outermost div Of width and height 50%

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta http-equiv="X-UA-Compatible" content="IE=edge">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <title>Document</title>    <style> *{ margin: 0; padding: 0; } .box{ background-color: aqua; width: 1200px; height: 400px; margin: 0 auto; } .box .border { width: 400px; height: 100px; background-color: black; } li{ list-style: none; float: left; color: red; background-color: pink; margin: 50% auto ; } ul{ width: 200px; height: 70px; background-color: yellow; } </style></head><body>        <div class="box">        <div class="border">            <ul>                <li>123</li>                <li>456</li>                <li>asd</li>                    </div>        </ul>    </div></body></html>

img




Take the answer :

??

img


copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/04/202204290658216869.html

Random recommended