Questions about page template

Hello. I am looking at the page template that I created long ago, and trying to modify it so that it will be responsive.

Below is a revision of my old, non-responsive page template…

<!DOCTYPE HTML>
<html lang="en">

<!-- *************************  HTML HEAD  ********************************* -->
<head>
  <!-- METADATA -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">

  <!-- TITLE -->
  <title>sp_pageWrapper.html</title>

  <!-- CSS STYLES -->
  <style media="screen">
    *{
      margin: 0;
      padding: 0;
    }
    
    html, body{
      height: 100%;
    }
    
    #pageWrapper{
      position: relative;
      display: block;
      min-height: 100%;
      max-width: 1200px;
/*      min-width: 800px;         /**/
      margin: 0 auto;
    }
    
    #pageInner{
      position: relative;
      width: 100%;
      overflow: hidden;
    }
    
    #mast{
      padding: 5px 0 0 0;
    }
    
    #topRow{
      display: flex;
      align-items: baseline;
      padding: 0 0 5px 0;
      line-height: 1.4;
    }
    
    #logo{
      font-family: Georgia, Times New Roman, Serif;      
      font-size: 2.1rem;
      font-weight: normal;
    }

    #menuLinks{
      margin-left: auto;
    }
    
    #topMenu{
/*      width: 1200px;   /**/
      width: auto;
      display: flex;
      flex-wrap: wrap;                          /* Added 2020-01-02 */
      list-style: none;
      background-color: #48D1CC;                /* Medium Turquoise */
    }

    #topMenu li{
      padding: 0.5em 1em;
      background-color: #48D1CC;                /* Medium Turquoise */
    }
    
    #topMenu li.menuCurrent{
      border: none;
      background-color: #008B8B;                /* Dark Cyan */
    }
        
    #pageBody{
      position: relative;
      max-width: 100%;
      margin: 30px 0 0 0;
      background-color: #EEE;
    }

  </style>
</head>

<!-- *************************  HTML BODY  ********************************* -->
<body>
  <div id="pageWrapper">
    
    <div id="pageInner">
      
      <!-- MAST -->
      <div id="mast">
        
        <!-- Top Row -->
        <div id="topRow">
          <h1 id="logo">Bob's Hardware</h1>
        </div>
        
        <!-- Top Menu -->
        <ul id="topMenu">
          <li class="menuCurrent">Home</li>
          <li>Nuts</li>
          <li>Bolts</li>
          <li>Washers</li>
          <li>Screws</li>
        </ul>        
      </div><!-- End of MAST -->
      
      <!-- CONTENT BODY -->
      <div id="pageBody">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id justo rhoncus, finibus nisl sit amet, pretium nibh. Aliquam nec turpis auctor justo fringilla aliquet et vitae magna. Vestibulum est mauris, condimentum id pulvinar sed, volutpat eu massa. Morbi cursus lacus in lectus venenatis gravida. Ut facilisis mollis hendrerit. Maecenas a nunc erat. Quisque erat arcu, facilisis sed consectetur vel, efficitur at quam. Pellentesque semper est nec arcu imperdiet, id facilisis neque luctus. Cras in rutrum ante, nec fringilla tortor. Pellentesque ac nibh volutpat, bibendum mi non, ultricies nisl. Sed malesuada condimentum nunc ut imperdiet. Pellentesque faucibus eu lorem aliquam volutpat. Duis gravida aliquet ultricies. Nam eu tempus lectus.</p>

        <p>Duis semper commodo gravida. Aenean dolor mauris, laoreet nec tempus id, congue vitae enim. Morbi at ultrices nisl. Maecenas quis lorem sollicitudin, fringilla elit eget, mollis velit. Morbi gravida consequat nisl, eget accumsan velit. Ut feugiat quis diam ac aliquam. Aenean ornare placerat hendrerit. Donec vel nulla quis sapien laoreet dictum et id nulla.</p>

        <p>Donec eleifend porta ullamcorper. Sed diam tortor, ornare vel gravida non, tristique in sem. Sed vel condimentum odio. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis eros libero, gravida at egestas ac, ultricies in erat. Vestibulum condimentum lorem in erat mollis, in fermentum orci consectetur. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum venenatis pulvinar ullamcorper. Etiam sollicitudin vitae metus vel posuere. Quisque viverra, libero id egestas consequat, ipsum lorem varius arcu, semper condimentum ex eros id ex. Curabitur tincidunt felis ultrices, blandit ipsum in, vestibulum mauris.</p>

        <p>Nam ullamcorper diam nunc, sed dignissim augue lacinia ac. Quisque bibendum ipsum consequat, aliquet metus a, tempor elit. Suspendisse porta dui eget lacinia maximus. Donec non sem aliquet, varius urna sit amet, rhoncus dolor. Curabitur nulla sem, finibus sit amet aliquam in, viverra vitae dolor. Suspendisse quis luctus massa, at rutrum ante. Etiam pharetra, metus tempor pharetra molestie, magna dui iaculis ligula, vel suscipit libero odio nec orci.</p>

        <p>Cras condimentum feugiat urna, sagittis viverra lacus consectetur at. Morbi id ex eget urna fermentum tempor ac a enim. Fusce sed vestibulum ipsum. Nunc convallis, ex ut fringilla euismod, dolor felis fringilla mauris, eget bibendum urna justo ut est. Donec consectetur sapien non ultricies viverra. Nam congue vel dolor nec iaculis. Pellentesque imperdiet nibh risus, at facilisis metus aliquam porttitor. Mauris malesuada nec nisi ac pellentesque. Vivamus cursus feugiat mi, at interdum magna suscipit a. Suspendisse potenti. Donec lacinia posuere ex sit amet interdum. Aliquam nec ex mi. Vivamus nec euismod tellus. Vestibulum rhoncus placerat sollicitudin. Nam facilisis non metus ut tincidunt. Vivamus eget semper elit.</p>
      </div>
      
    </div>
    
  </div>
  
</body>
</html>

Questions:
1.) Is my #pageWrapper okay?

2.) Any idea why I would have put a min-width on #pageWrapper?

3.) Any idea why I would have created #pageInner?

Does it serve any useful purpose?

4.) Does #pageWrapper have to be a Flexbox to make my web pagesresponsive?

Hi there UpstateLeafPeeper,

here is your code with amendments…

<!DOCTYPE HTML>
<html lang="en">

<!-- *************************  HTML HEAD  ********************************* -->
<head>
  <!-- METADATA -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">

  <!-- TITLE -->
  <title>sp_pageWrapper.html</title>

  <!-- CSS STYLES -->
  <style media="screen">
    *{
      margin: 0;
      padding: 0;
    }
    
    html, body{
      /*height: 100%;*/
    }
    
    #pageWrapper{
      /*position: relative;
      display: block;
      min-height: 100%;*/
      max-width: 75em;
/*      min-width: 800px;         /**/
      margin: 0 auto;
      padding: 5px 0 0 0;
    }
    
/*    #pageInner{
      position: relative;
      width: 100%;
      overflow: hidden;
    }
 */   
/*    #mast{
      padding: 5px 0 0 0;
    }
 */   
   /* #topRow*/ h1{
      /*display: flex;
      align-items: baseline;*/
      padding: 0 0 5px 0;
      line-height: 1.4;
    }
    
    #logo{
      font-family: Georgia, Times New Roman, Serif;      
      font-size: 2.1rem;
      font-weight: normal;
    }

    #menuLinks{
      margin-left: auto;
    }
    
    #topMenu{
/*      width: 1200px;   /**/
      width: auto;
      display: flex;
      flex-wrap: wrap;                          /* Added 2020-01-02 */
      list-style: none;
      background-color: #48D1CC;                /* Medium Turquoise */
    }

    #topMenu li{
      padding: 0.5em 1em;
      background-color: #48D1CC;                /* Medium Turquoise */
    }
    
    #topMenu li.menuCurrent{
      border: none;
      background-color: #008B8B;                /* Dark Cyan */
    }
        
    #pageBody{
      /*position: relative;
      max-width: 100%;*/
      margin: 2em 0 0 0;
      padding: 1px 0;
      background-color: #EEE;
    }
    #pageBody p {
      margin: 1em;
    }
  </style>
</head>

<!-- *************************  HTML BODY  ********************************* -->
<body>
  <div id="pageWrapper">
    
      
      <!-- MAST -->
      <!--<div id="mast">-->
        
        <!-- Top Row -->
        <!--<div id="topRow">-->
          <h1 id="logo">Bob's Hardware</h1>
      <!--  </div>-->
        
        <!-- Top Menu -->
        <ul id="topMenu">
          <li class="menuCurrent">Home</li>
          <li>Nuts</li>
          <li>Bolts</li>
          <li>Washers</li>
          <li>Screws</li>
        </ul>        
     <!-- </div>--><!-- End of MAST -->
      
      <!-- CONTENT BODY -->
      <div id="pageBody">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id justo rhoncus, finibus nisl sit amet, pretium nibh. Aliquam nec turpis auctor justo fringilla aliquet et vitae magna. Vestibulum est mauris, condimentum id pulvinar sed, volutpat eu massa. Morbi cursus lacus in lectus venenatis gravida. Ut facilisis mollis hendrerit. Maecenas a nunc erat. Quisque erat arcu, facilisis sed consectetur vel, efficitur at quam. Pellentesque semper est nec arcu imperdiet, id facilisis neque luctus. Cras in rutrum ante, nec fringilla tortor. Pellentesque ac nibh volutpat, bibendum mi non, ultricies nisl. Sed malesuada condimentum nunc ut imperdiet. Pellentesque faucibus eu lorem aliquam volutpat. Duis gravida aliquet ultricies. Nam eu tempus lectus.</p>

        <p>Duis semper commodo gravida. Aenean dolor mauris, laoreet nec tempus id, congue vitae enim. Morbi at ultrices nisl. Maecenas quis lorem sollicitudin, fringilla elit eget, mollis velit. Morbi gravida consequat nisl, eget accumsan velit. Ut feugiat quis diam ac aliquam. Aenean ornare placerat hendrerit. Donec vel nulla quis sapien laoreet dictum et id nulla.</p>

        <p>Donec eleifend porta ullamcorper. Sed diam tortor, ornare vel gravida non, tristique in sem. Sed vel condimentum odio. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis eros libero, gravida at egestas ac, ultricies in erat. Vestibulum condimentum lorem in erat mollis, in fermentum orci consectetur. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum venenatis pulvinar ullamcorper. Etiam sollicitudin vitae metus vel posuere. Quisque viverra, libero id egestas consequat, ipsum lorem varius arcu, semper condimentum ex eros id ex. Curabitur tincidunt felis ultrices, blandit ipsum in, vestibulum mauris.</p>

        <p>Nam ullamcorper diam nunc, sed dignissim augue lacinia ac. Quisque bibendum ipsum consequat, aliquet metus a, tempor elit. Suspendisse porta dui eget lacinia maximus. Donec non sem aliquet, varius urna sit amet, rhoncus dolor. Curabitur nulla sem, finibus sit amet aliquam in, viverra vitae dolor. Suspendisse quis luctus massa, at rutrum ante. Etiam pharetra, metus tempor pharetra molestie, magna dui iaculis ligula, vel suscipit libero odio nec orci.</p>

        <p>Cras condimentum feugiat urna, sagittis viverra lacus consectetur at. Morbi id ex eget urna fermentum tempor ac a enim. Fusce sed vestibulum ipsum. Nunc convallis, ex ut fringilla euismod, dolor felis fringilla mauris, eget bibendum urna justo ut est. Donec consectetur sapien non ultricies viverra. Nam congue vel dolor nec iaculis. Pellentesque imperdiet nibh risus, at facilisis metus aliquam porttitor. Mauris malesuada nec nisi ac pellentesque. Vivamus cursus feugiat mi, at interdum magna suscipit a. Suspendisse potenti. Donec lacinia posuere ex sit amet interdum. Aliquam nec ex mi. Vivamus nec euismod tellus. Vestibulum rhoncus placerat sollicitudin. Nam facilisis non metus ut tincidunt. Vivamus eget semper elit.</p>
      </div>
      

    
  </div>
  
</body>
</html>

The page is/was responsive but needs
the hamburger effect that you like.

I have left that in your capable hands. :biggrin:

coothead

@coothead,

1.) Why did you comment out…

    html, body{
      /*height: 100%;*/
    }

2.) Why did you comment out…

    #pageWrapper{
      /*position: relative;
      display: block;
      min-height: 100%;*/
      max-width: 75em;
/*      min-width: 800px;         /**/
      margin: 0 auto;
      padding: 5px 0 0 0;
    }

3.) So I guess ths wasn’t needed, huh? Any ideas why I might have needed it in the past?

/*    #pageInner{
      position: relative;
      width: 100%;
      overflow: hidden;
    }
 */   

4.) Why did you comment out what you did?

Why did I havemax-width: 100%;?

    #pageBody{
      /*position: relative;
      max-width: 100%;*/
      margin: 2em 0 0 0;
      padding: 1px 0;
      background-color: #EEE;
    }

So it sounds like what I had in my OP was okay, but just needed some tweaks?

Surplus to requirements.

That is beyond my remit. :rofl:

Yes, that is true, :winky:

coothead

I thought you always needed height: 100%; to ensure the container always stretches to fit the screen?


Similar to #1, I thought you needed min-height: 100%; to ensure the container stretches to fit the screen? (In the old days I am certain this was true…)

Also, doesn’t display: block; fill the screen?

Hi there UpstateLeafPeeper,

there was nothing in your HTML
that suggested a need for…

  html, body{
      height: 100%;
    }
 #pageWrapper{
      min-height: 100%;
    }

coothead

I just remember that was code that you were always supposed to add - at least that is what I remember - and so I am trying to understand the logic between why you need that code - at least in the past.

Here is a link about what I was thinking about…

https://stackoverflow.com/questions/6654958/make-body-have-100-of-the-browser-height

Hi there UpstateLeafPeeper,

what you should be thinking about is not the possibility of
making the body height the same as that of the browser
but in what circumstances would it be required. :biggrin:

Also note that…

CSS - vh

…is now available and probably a little less convoluted to
work with. :winky:

coothead

2 Likes

I think I needed it in the past when I wanted to shade the background of the entire web page. Maybe I needed it for other applications, but I don’t recall.

Yeah, I saw that, but I think I’ll stay with what has worked in the past.

Oh ye of little faith, what is so hard to understand
about this…

<!DOCTYPE HTML>
<html lang="en">
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">

<title>Untitled document</title>

<!--
The internal CSS should be transferred to an external file
<link rel="stylesheet" href="screen.css" media="screen">
-->

<style media="screen">
body {
    margin: 0;
    background-color: #f0f0f0;
    font: normal 1em / 1.62em sans-serif;
 } 

 div {
    max-width: 62em;
    height: 100vh;
    padding: 2em;
    margin: auto;
    border: 1px solid #999;
    background-color: #eff;
    box-sizing: border-box;
    box-shadow: inset 0 0 1em rgba( 0, 0, 0, 0.4 ), 
                0 0.4em 0.4em rgba( 0, 0, 0, 0.4 );
 }
</style>

</head>
<body>

 <div>
  <p>
   "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed 
    do eiusmod tempor incididunt ut labore et dolore magna aliqua."
  </p>
 </div>

</body>
</html>

coothead

Well, I wasn’t entirely sure how to use vh.

In this link, they put vh in two places…

body {
  height: 100vh;
  padding: 0;
}
body {
  min-height: 100vh;
  padding: 0;
}

No problem, just change height to min-height here…

 div {
    max-width: 62em;
    min-height: 100vh;
    padding: 2em;
    margin: auto;
    border: 1px solid #999;
    background-color: #eff;
    box-sizing: border-box;
    box-shadow: inset 0 0 1em rgba( 0, 0, 0, 0.4 ), 
                0 0.4em 0.4em rgba( 0, 0, 0, 0.4 );
 }

Job done. :rofl:

coothead

@coothead,

1.) Why do I need both

height: 100vh;
min-height: 100vh;

2.) Shouldn’t those go in the body instead of in your {b]div[/b]?

You don’t. :winky:

No. :winky:

If you test my code, you will see that it confirms my assertion. :biggrin:

coothead

Hmmm…

Yes, I looked at your code and web page.

It looks like from the other link you could put the vh in either body or your div.

Subtle differences that make me nervous, but okay.

I read up on Flexbox earlier this year and it sorta made sense, but since then I have forgotten most of what I learned.

What would be the pros and cons of using my old approach…

#pageWrpper{
	display: block;
	max-width: 1200px;
	min-height: 100vh;
	margin: 0 auto;
}

versus using the newer Flexbox approach?

#pageWrapper{
	display: flex;
	box-sizing: border-box;
	margin: 0 auto;
}

Years ago, I created a page wrapper so I could do things like add margins on the sides if I wanted, and I suppose that is the main reason, since you cannot do that with < body >

The idea of my page wrapper is it is part of my template that I will use on every web page on my website. So I want something that is adaptable and that plays well with a responsive design.

At the same time, often I will just have one article on a page or a couple of items wher I don’t need/want them shifting around like my top menu as the screen gets smaller, so right now I’m not sure the second style is all that beneficial.

But as I was playing around with making a responsive table a few days ago, I created a #wrapper that uses the code in the 2nd example, so now I wonder if it might make sense to use that in my page “template”, but I just don’t know…

Hi there UpstateLeafPeeper,

to me, it now sounds as though you are just thinking aloud. :winky:

What you really should be doing instead is practicing coding.

There’s more than one way to skin a cat, and practice will show
you the method that best suits your needs.

Further more, practicing will uncover the pros and cons that
will apply to the various methods that you try.

coothead

1 Like

Well, I somewhat varified that my template is responsive, and I was trying to figure out the best ay to handle my page wrapper.

Yeah, but I have coded things both ways, and it isn’t entiely clear to me the pros and cons of each approach, so I am asking here… :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.