Move right column up

I am using the @media query and I am trying to make the right column to go to the beginning of the .left div when compressing the screen. For now, I can make it jump to the top of the .middle div. I tried to play with positioning, but it seems that it does not work the way I need.

I need this structure in compression:

Left column | Right column
middle column

Right now:

Left Column
Middle Column | Right column

See code below. Thanks.

div {
    border-radius: 4px;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -ms-box-sizing: border-box;
    box-sizing: border-box;
}
#header {
    height: 52px;
    width: calc(100% - 16px);
    background-color: #B2D490;
    z-index: 1;
    position: fixed;
    top: 10px;
}
h1 {
    color: #FFFFFF;
    padding-left: 25px;
    margin: 0;
    display: inline;
    font-size: 27px;
    line-height: 50px;
}
h2, h3, h4, h5, h6 {
    padding-left: 10px;
    margin: 10px 0 10px 0px;
    color: #00457D;
}
.left {
    width: 300px;
    background-color: #C7E6FF;
    float: left;
    margin-top: 64px;
    margin-right: calc(50% - 450px);
}
.middle {
    width: 300px;
    background-color: #DEF0FF;
    margin-top: 64px;
    float: left;
}
.right {
    width: 300px;
    background-color: #C7E6FF;
    float: right;
    margin-top: 64px;
}
#footer {
    height: 35px;
    width: 100%;
    background-color: #57C449;
    clear: both;
    position: relative;
    margin-top: 10px;
}
p {
    color: #00579E;
}
#footer p {
    color: #FFFFFF;
    text-align: center;
    margin: auto;
    line-height: 35px;
}
span {
    color: #D4EBFF;
}

@media screen and (max-width: 980px) {
  body {
      width: 95%;
  }
   .left {
      width: 60%;
      margin-right: 0;
     
   }
   .middle {
      width: 60%;
      margin-top: 10px;
   
   }
   .right {
      width: calc(40% - 10px);
      margin-top: 10px;


      
   }
}
<head>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<title>My Resume</title>
	</head>
	<body>
	<div id="header">
	    <h1>My <span>Resume</span></h1>
	</div>
	<div class="left">
	    <h2>Left Column</h2>
	        <ul>
	            <p>Some Text</p>
	            <p>Some Text</p>
	            <p>Some Text</p>
	            <p>Some Text</p>
	            <p>Some Text</p>
	        </ul>
	</div>
		<div class="middle">
	    <h2>Centered Center Column</h2>
	        <ul>
                <li><p>Some Text</p></li>
                <li><p>Some Text</p></li>
                <li><p>Some Text</p></li>
        </ul>
	</div>
	<div class="right">
	    <h4>Right Column</h4>
	        <ul>
	            <p>Some Text</p>
	            <p>Some Text</p>
	            <p>Some Text</p>
	       </ul>
	</div>
	<div style="clear:both; border:none; border-radius: none;"></div>
	<div id="footer">
	    <p>© 2015 Me - the Programmer</p>
	</div>
Run codeHide result
+4
source share
1 answer

try it

.right {
    width: 300px;
    position: absolute; //added this
    background-color: #C7E6FF;
    right: 0; //added this
    margin-top: 64px;
}

In a multimedia query, use this class

 .right {
      width: calc(40% - 10px);
      margin-top: 64px;  //changed this 
   }

Demo here

+1
source

Source: https://habr.com/ru/post/1606754/


All Articles