Elton Sousa Elton Sousa - 6 months ago 9
CSS Question

Changing the color of a box in css

I am trying to change the colors of the boxes that I have in the HTML code with the css code that you can see below but for some reason the color does not change.

<div class="menu">
<ul>
<li>The Flight</li>
<li>The City</li>
<li>The Island</li>
<li>The Food</li>
</ul>
</div>

<div class="main">
<h1>The City</h1>
<p>Chania is the capital of the Chania region on the island of Crete. The city can be divided in two parts, the old town and the modern city.</p>
<p>Resize the browser window to see how the content respond to the resizing.</p>
</div>


The css is as it follows

* {
box-sizing: border-box;
}

.menu{
width:25%;
float: left;
border:1px solid red;
height:75%;
}

.main{
width:75%;
height:75%;
float: left;
border:1px solid red;
}


How can I change the color of the boxes(grids)?
I am also adding the online code in case someone prefers to see :
https://jsfiddle.net/Wosley_Alarico/b2htLvcj/

Answer

Just add in css background:colorcode;

Like This:
* {
    box-sizing: border-box;
}



.menu{
    width:25%;
    float: left;
    border:1px solid red;
     height:75%;
     background:lightblue;
}

.main{
    width:75%;
    height:75%;
    float: left;
    border:1px solid red;
    background:skyblue;
}

<div class="menu">
            <ul>
                <li>The Flight</li>
                <li>The City</li>
                <li>The Island</li>
                <li>The Food</li>
            </ul>
        </div>

        <div class="main">
            <h1>The City</h1>
            <p>Chania is the capital of the Chania region on the island of Crete. The city can be divided in two parts, the old town and the modern city.</p>
            <p>Resize the browser window to see how the content respond to the resizing.</p>
        </div>  

Jsfiddle link : https://jsfiddle.net/b2htLvcj/1/

Comments