Trouble defining width of a responsive div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

Trouble defining width of a responsive div

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Lorem ipsum dolor sit amet, </title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
body {<!--from ww w  . j  a  v a2 s.  c  o  m-->
   width:100%;
   max-width:100%;
   overflow-x:hidden;
}

.wrapper {
   width:87%;
   max-width:1351px;
   margin:0 auto;
   background:Chartreuse;
   position:relative;
}

.contentwrapper {
   height:301px;
   width:100%;
   padding-right:calc((100vw - 100%) / 3);
}

html,
body {
   background:yellow;
   margin:0;
   padding:0;
   font-family:sans-serif;
}

.contentwrapper {
   background:blue url('https://www.java2s.com/style/demo/Google-Chrome.png') no-repeat;
   background-size:cover;
   margin-bottom:31px;
}

.content {
   padding:2em;
}

#freelancewrapper {
   color:pink;
   padding:2em 3em;
   height:100%;
   position:relative;
}

#freelancewrapper p {
   background:OrangeRed;
   width:61%;
   height:61%;
   padding:2em;
   font-weight:bold;
   position:absolute;
   bottom:-21px;
   overflow:hidden;
}
</style> 
 </head> 
 <body> 
  <!-- main wrapper --> 
  <div class="wrapper"> 
   <!-- some content at top --> 
   <div class="content"> 
    <h3>Lorem ipsum dolor sit amet</h3> 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed q</p> 
   </div> 
   <!-- div that expands to end of viewport (right side) --> 
   <div class="contentwrapper"> 
    <section id="freelancewrapper"> 
     <h1>Lorem ipsum dolor sit amet, co</h1> 
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed quam pharetra, tincidunt tortor in, pharetra nisl. Maecenas aliquam luctus mauris, vitae venenatis diam imperdiet vel. Donec tortor diam, pretium vitae nibh vitae, consect</p> 
    </section> 
   </div> 
   <!-- more content below --> 
   <div class="content"> 
    <h3>Lorem ipsum dolor sit amet</h3> 
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed quam pharetra, </p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials