简体   繁体   中英

my second div where I put my unordered list not displaying ?

I'm trying to create a To-Do list app and when I'm getting to the second div where I want to create the unordered list, it is not displaying and I don't seem to know why it is not displaying. I've tried erasing that div and creating a enw one and writing a simple hello message but not even that displays. I'm guessing it has something to do with the first div for not allowing it.

<!doctype html>
<html>
<head>
      <title>To Do list</title>

    <style type="text/css">

        #topBar-div{
            background-color: #F44336;
            position:absolute;
            top: 0px;
            width:100%;
            height: 150px;

        }

        body{
            margin: 0px;
            padding: 0px;
        }

        h1{
            color:white;
            margin-left: 300px;
        }

        #textInput{
            height: 30px;
            margin-left: 100px;
            width: 600px;
            font-size: 20px;
            color: #8E8E8E;
        }

        #addButton{
            height:37px;
            position:relative;
            top:-4px;
            right: 5px;
            width: 70px;
            color: grey;

        }

        #secondBar-div{
            color: grey;
            height: 350px;
            width: 1000px;
        }


    </style> 

</head>

<body>
    <div id="topBar-div">

        <h1>My To Do List</h1>

        <input type="text" value="Title..." id="textInput">

        <button id="addButton">Add</button>

    </div>

    <div id="secondBar-div">

        <ul>

            <li>Hit the gym</li>
            <li>Pay bills</li>
            <li>Meet George</li>
            <li>Buy eggs</li>
            <li>Study</li>
            <li>Cook Dinner</li>

        </ul>


    </div>


    <script type="text/javascript">


    </script>

</body>
</html>

You are using position absolute in the style of the first div (topBar-div) so your second div (secondBar-div) moves up and is actually behind that first div.

Try adding this to #secondBar-div

margin-top: 150px;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM