TABLELESS: 4-Column Float

Folks, this is such a disaster I gave up and made a graphic of the desired output, below. This is part of my Library project, and will sit on top of the other content. I’m trying to go tableless and it’s been awhile since I did FLOATS. Some of this I got from ronpat (thanks buddy), and Paul I have tidied it so if you don’t like it, it isn’t my fault! :eyes:
##Float Within a Float###
4 containers span the width of the page (using the body margins). The 4 containers will have a border and 30px between them. Note, I’ve given the container columns a width of 20% as temporary placeholders. In each of these containers are going to be the library hours of 4 libraries in three columns. The center most column I’m displaying as blue lines are seven ndash characters, as in
9:30 AM – 5:00 PM
for the 7 days of the week. Obviously that center column does not have left & right borders, this is just for the layout. The columns appearing to the left of their ndash will be text-align: right;

I was trying to make the class .FOCUS the inner float (the 9:30 AM – 5:00 PM bit). Oh yes and I just added a header to each of them, which is new so I’ve updated the graphic. Thank you for your help friends.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
     <meta name="generator" content=
     "HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" />
     <meta content="text/html charset=UTF-8 http-equiv=Content-Type" />

     <title>LIBRARY HOURS &#9679; 2018-03-30</title>
     <style type="text/css">
/*<![CDATA[*/

     *, *:before, *:after {
     -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
        box-sizing: border-box;
     }

     a:link {color: #6AB343;}    */ LIGHT GREEN
     a:visited {color: #018A00;} */ DARK GREEN
     a:hover {color: TEAL;}
     a:active {color: BLACK;}

     .BLINKS
     a:link {color: #006ED5;}
     a:visited {color: #006ED5;}
     a:hover {color: BLUE;}
     a:active {color: BLUE;}

     P {margin-TOP: 0px;
     margin-BOTTOM: 0px;
     margin-LEFT: 0px;
     margin-RIGHT: 0px;
     }

     H1 {margin: 0px 0 10px 0;}
     H2 {margin: 0px 0 10px 0;}
     H3 {margin: 0px 0 5px 0;}
     H4 {margin: 0px 0 0px 0;}
     H5 {margin: 0px 0 0px 0;}

     thead {
     background: #6AB343;
     border-bottom: 6px solid #000000; */ Defining the header's background and border(s) */
        padding: 10px;
     }

     thead th {  */ Defining the HEADER'S FONT properties */
      color: #018A00; 
     border: 1px solid BLACK;
     padding: 10px;  /* padding is the CSS equivalent of TABLE cellpadding */
     font-family: PRESTIGE12 BT, MONOSPACE;
     font-size: 18px;
     line-height: 18px;
     font-weight: bold;
     text-align: left;
     }

     td, th {
     padding-left: 8px;
     padding-right: 8px;
     padding-top: 1px;
     padding-bottom: 1px;
     }

     BODY {font-family: PRESTIGE12 BT, MONOSPACE;
     font-size: 18px;
     line-height: 18px;
     text-align: LEFT;
     margin-left: 30px;
     margin-right: 30px;
     margin-top: 30px;
         width: AUTO;
     overflow: hidden;
     }

     .colm1, .colm2, .colm3, .colm4 {
     padding: 10px 1%;
     border-right: 2px DOTTED #018A00;
     }

     .colm1 {
     float: LEFT;
     color: #000000;
     width: 20%;
     text-align: LEFT;
     }

     .colm2 {
     float: LEFT;
     color: #000000;
     width: 20%;
     text-align: LEFT;
     }

     .colm3 {
     float: LEFT;
     color: #000000;
     width: 20%;
     text-align: LEFT;
     }

     .colm4 {
     float: RIGHT;
     color: #000000;
     width: 20%;
     text-align: LEFT;
     }

     .FOCUS {
     text-align: LEFT;
     float: left;
     width: 10%;}
     }

     /*]]>*/
     </style>
</head>

<body>
     <div class="colm1">
          <div class="FOCUS">
               <div>
                    OPEN
               </div>

               <div>
                    &amp; &ndash;
               </div>

               <div>
                    CLOSE
               </div>
          </div>

          <div class="colm2">
               <div class="FOCUS">
                    <div>
                         OPEN
                    </div>

                    <div>
                         &amp; &ndash;
                    </div>

                    <div>
                         CLOSE
                    </div>
               </div>

               <div class="colm3">
                    <div class="FOCUS">
                         <div>
                              OPEN
                         </div>

                         <div>
                              &amp; &ndash;
                         </div>

                         <div>
                              CLOSE
                         </div>
                    </div>

                    <div class="colm4">
                         <div class="FOCUS">
                              <div>
                                   OPEN
                              </div>

                              <div>
                                   &amp; &ndash;
                              </div>

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

Okay I have made a crude start and you can see it here.

Hi semicolon,
You don’t really need floats to do this layout.

For the hours, that could just be a list with each li set to text-align center. Unless there is more to it that I’m no aware of. Still wouldn’t see any need for floats.

As far as the four containers, flexbox can set them in a row.

See if this is something you can work with.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Library Hours</title>
<style>

.wrap {
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
}
.hours {
  width: 20%;
  min-width: 150px;
  margin: 5px 15px;
  border: 1px solid;
  text-align: center;
}
.hours h2 {
  font-size: 1.5em;
  margin: 0;
  padding: .25em;
}
.hours p {
  font-size: 1em;
  margin: .30em;
}
.hours ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid;
}
.hours li {
  padding: .30em;
  border-bottom: 1px solid;
}
.hours li:last-child {border:none}

</style>

</head>
<body>

<div class="wrap">
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
      <li>9:30 AM &ndash; 5:00 PM</li>
    </ul>
  </div>
</div>

</body>
</html>
2 Likes

Yo Ray. I want complete control over how the hours display, so I don’t think this will work for me. They need to snap to their ndashes, and I need to be able to style specific sections.

REV. 02

There’s something aesthetically beautiful about a layout such as this one you uploaded. Clean. Readable. Very nice concept and I’m saving it. Thanks Ray. Yea wouldn’t it be nice if they all had the same hours . . . no holidays . . . no special events . . . no You get the idea lol.

I’ve given you your own folder! There is no higher praise lol :stuck_out_tongue_closed_eyes:

Just so you know, an <li> can have a div or span etc. nested within it. That div or span could have unlimited possibilities. :slight_smile:

The code was just a starting point.

Well then . . . how is this better than floats? Isn’t it a <DIV> by any other name?

I guess what I’m asking is , , , is there some advantage <LI>s have that floats do not?

As for my code:
Why on earth can’t I get my simple float to display correctly? arrrrrgh. Why is it jumping the row?

Floats are just part of the visual formatting model, you can float any html element whether it’s a <div>, a <li> or a <p> tag doesn’t matter.

What this is really about is trying to select the right element to give your content some semantics. I chose an unordered list because I see a list of hours. From there you can style each <li> as needed for holidays or whatever may be needed. You can set different classes on special list items or nest other elements within to get a different structure within special cases.

If you can tell us more about your actual content (or make another image) then we can adjust the code to fit your needs.

EDIT:
Back to the floats…

We have modern layout techniques now that have pretty much taken the place of floats.
The only time you really need a float is when you need text to wrap around that block. Such as with a floated image that has text wrapping around it. That was the original intention of floats, then floats started being used in layouts to set columns beside each other.

4 Likes

Well first I have to apologize because this started out being about hours and at some point I added contact & location data, probably confusing everyone. Let’s just . . . er set aside the Contact and other info which will be in straight rows and focus on the 3 columns within your .WRAP.

Alright Ray, I’m going for it.

We have a little <LI>.
Now on the line that this little <LI> starts I need to get 3 columns, the middle being the ndashes (the blue in my graphic).

<LI> … 12:00 PM … … 8:30 PM … </LI>

Is this the basic concept? And obviously we have to divide it into columns but because I don’t know how to do that I’m just taking it from the top. We insert what to get the columns?

We have modern layout techniques now that have pretty much taken the place of floats.

Okay, that’s important for me to know. Thank you Ray.

And please, whenever you see me doing that let me know. I don’t do this for a living so what the float do I know!? :stuck_out_tongue_winking_eye:

2 Likes

Okay so it seems that the dash being nested in it’s own container is important to your layout. So as you say you need three columns for each day in your list of hours.

We’re not committed to an <li>, but it still looks like a list of hours to me so that is what I would work with.

Give me a minute and let me put some html together for those changes.

As you requested here is the revised list structure with three columns.
I’m setting the dash in a span since it is generic inline content, then I’m setting the hours in a div which will allow you to do further nesting should it be necessary.

    <ul>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
    </ul>

Now you will have full control of styling and you could add some classes to those divs for further special case styling.

To keep those columns in a row I’m using flexbox again and the I’m styling the nested elements as shown below. The background colors are just temporary styles so you can see it hit the target.

.hours li {
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  align-items: center;
  padding: .30em;
  border-bottom: 1px solid;
}
    .hours li div:first-child {
      background:palegreen;
      padding:0 .25em;
    }
    .hours li span {
      margin: 0 5px;
      font-weight:bold;
    }
    .hours li div:last-child {
      background:yellow;
      padding:0 .25em;
    }
.hours li:last-child {border:none}

Then roll it all together with the previous code I posted.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Library Hours</title>
<style>

.wrap {
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
}
.hours {
  width: 20%;
  min-width: 150px;
  margin: 5px 15px;
  border: 1px solid;
  text-align: center;
}
.hours h2 {
  font-size: 1.5em;
  margin: 0;
  padding: .25em;
}
.hours p {
  font-size: 1em;
  margin: .30em;
}
.hours ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid;
}
.hours li {
  display: flex;
  flex-flow: row nowrap;
  justify-content: center;
  align-items: center;
  padding: .30em;
  border-bottom: 1px solid;
}
    .hours li div:first-child {
      background:palegreen;
      padding:0 .25em;
    }
    .hours li span {
      margin: 0 5px;
      font-weight:bold;
    }
    .hours li div:last-child {
      background:yellow;
      padding:0 .25em;
    }
.hours li:last-child {border:none}

</style>

</head>
<body>

<div class="wrap">
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
      <li><div>9:30 AM</div><span>&ndash;</span><div>5:00 PM</div></li>
    </ul>
  </div>
</div>

</body>
</html>
2 Likes

Hi Ray good example but I see a small problem with that approach :slight_smile:

If for example the hours are different times (you have them all the same) and some were say 12:30 - 5:00 (or whatever) then the n-dash in the middle would not line up uniformly in a vertical column (see screenshot below. You could fix this with flex by giving a basis to the left and right items and within reason that will stay together.

As you can see the dash will be nicely centred now.

Bearing in mind that flexbox relationship is linear and does not do columns explicitly I would prefer to use display:table/row/cell to create that layout so that it is foolproof (or css grid if only modern support is required).

The html code is exactly the same but we just change the relevant css to the table properties.

e.g.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Library Hours</title>
<style>
.wrap {
	display: flex;
	flex-flow: row wrap;
	justify-content: center;
}
.hours {
	width: 20%;
	min-width: 150px;
	margin: 5px 15px;
	border: 1px solid;
	text-align: center;
}
.hours h2 {
	font-size: 1.5em;
	margin: 0;
	padding: .25em;
}
.hours p {
	font-size: 1em;
	margin: .30em;
}
.hours ul {
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid;
	display:table;
	width:100%;
}
.hours li {
	display: table-row;
	padding: .30em;
	border-bottom: 1px solid;
}
.hours div, .hours span {
	display:table-cell;
	vertical-align:top;
}
.hours div {
	width:50%;
}
.hours li div:first-child {
	background:palegreen;
	padding:0 .25em;
	text-align:right;
}
.hours li span {
	padding: 0 5px;
	font-weight:bold;
}
.hours li div:last-child {
	background:yellow;
	padding:0 .25em;
	text-align:left
}
.hours li:last-child {
	border:none
}
</style>
</head>
<body>
<div class="wrap">
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li>
        <div>12:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>12:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
    </ul>
  </div>
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
      <li>
        <div>9:30 AM</div>
        <span>&ndash;</span>
        <div>5:00 PM</div>
      </li>
    </ul>
  </div>
</div>
</body>
</html>

Now the n-dash can never fail to be aligned vertically and neither can the text wander off.:slight_smile:

5 Likes

Good catch Paul, I had not done any thorough stress testing on it yet. :slight_smile:

Hi there semicolon,

I also prefer to use display: table etc. :winky:

Here is my take on it…

<!DOCTYPE HTML>
<html lang="en">
<head>
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self';script-src 'self'; style-src 'self'">-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">

<title>untitled document</title>

<link rel="stylesheet" href="screen.css" media="screen">

<style media="screen">
body {
    background-color: #f0f0f0;
    font: 100% / 162% verdana, arial, helvetica, sans-serif;
 }

h1 {
   font-size: 1.2em;
    text-align: center;
    text-transform: uppercase;
 }

.container {
    display: table;
    width: 100%;
    border-spacing:1em;
 }

.hours {
    display: table-cell;
    padding-bottom: 1em;
	border: 1px solid #999;
    border-radius: 0.5em;
	text-align: center;
    background: #fff;
    box-shadow: 0.43em 0.4em 0.4em rgba( 0, 0, 0, 0.3 );
 }

.hours h2 {
    font-size: 1.2em;
 }

.hours p {
    padding-bottom: 0.25em;
	border-bottom: 1px solid #999;
 }

.hours ul{
    display: table;
    width: 100%;
    padding: 0;
    margin: 0;
    list-style: none;
    border-spacing: 0;
 }
.hours li {
    display: table-row;
 }

.hours li span {
    display: table-cell;
    border-bottom: 1px solid #999;
 }
.hours li:last-of-type span {
    border-bottom: 0;
 }

@media ( max-width: 52em ) {
.container  {
    border-spacing: 0;
  }

.hours {
    float: left;
    width: 48%;
    margin: 1%;
    box-sizing: border-box;
  }
 }

@media ( max-width: 28em ) {
.hours {
    width: 98%;
  }
 }
</style>

</head>
<body> 
<h1>The Library</h1>
 <div class="container">
  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>12:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>12:00 PM</span></li>
    </ul>
  </div>

  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>12:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>12:00 PM</span></li>
    </ul>
  </div>

  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>12:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>12:00 PM</span></li>
    </ul>
  </div>

  <div class="hours">
    <h2>Library Hours</h2>
    <p>Monday through Sunday</p>
    <ul>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>12:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>&nbsp;5:00 PM</span></li>
      <li><span>&nbsp;9:30 AM</span><span>&ndash;</span><span>12:00 PM</span></li>
    </ul>
  </div>
<!-- .container --></div>

</body>
</html>

coothead

2 Likes

What’s up with the _style-src 'self'_ labels?

[quote=“PaulOB, post:12, topic:293559”]
If for example the hours are different times (you have them all the same) and some were say 12:30 - 5:00 (or whatever) then the n-dash in the middle would not line up uniformly in a vertical column (see screenshot below. [/quote]

@PaulOB Yeah, Paul nails it: Those pesky hours are most definitely not the same. It looks good Paul. @Ray.H Ray you have put so much work into this, I can’t thank you enough.

Okay I’ll tweak it a bit and upload the latest to cssdesk. I’m warning everybody: I’m gonna be a terror now that I know about display: flex.

:joy:

2 Likes

I have that “meta tag” In my HTML template and normally
remove it in it’s entirety when posting code here. :winky:

You may find out “What’s up with it” here…

Content Security Policy

I apologise for leaving it in my posted code and hope that
it did not cause an overly amount of aggravation for you. :biggrin:

coothead

###MY LATEST REVISION IS HERE###


UPPER/ Anchor Styling
So there are a bunch of things wrong with this but the most irritating one is why my anchor styling suddenly stopped working. I’ve scrutinized the code off of the last working iteration, and even flushed my history and cache, but I can’t get it to replicate. Sometimes it displays; sometimes it doesn’t. Those 3 links relate to my three uploads on cssdesk btw.

UPPER/ New 1st Column
The days need to line up with their rows (style .WEEK, line 87). I fooled around with the TH but that only broke other things. Spent hours on this.

UPPER/ Header Padding
I’m missing padding on TOP.

UPPER/ Double Spacing
My <p></p> line are supposed to represent ‘two carrier returns’. Everyone gets mad at me for using <BR><BR> (which I’d prefer) so give me some credit for attempting a <BR>-less page. Not styled with margins; just clean double spacing.


LOWER/ Error Header Background Color
There is no attribute “BGCOLOR” validation errors (lines 379 and 392).

LOWER/ Padding and Width
The text in all 7 of the MON-SUN columns should be aligned CENTER. And WEDNESDAY should set the baseline for the other 6 days’ width. I’m not pleased with the horizontal padding of these 7 columns generally, namely, there isn’t any. You can see my efforts on lines 98, 104, 110, and 121.

@coothead Coot, I’m using a MONOSPACE’d font; stick with the plan.

That’s it for now. Thanks everyone.

Oh dear, where do I start :slight_smile:

I’ll run through a few issues to discuss first before offering code but if I understand correctly where you mention the days of the week lining up with the times then you actually have tabular data with columns and row headings and the correct element to use for this is the html table element (not the css display:table properties). In fact you have marked your second set of data in a table so I don’t see how you can think the first one is different?

The first example is now pretty useless to assisted users because the days bear no relationship to anything and are meaningless. If they were in a table along with the times it would immediately have an undeniable relationship to each other and be visible easily to those using assistive technology and indeed any search engine looking at the code.

OK back to specific issues with the current code :slight_smile:

Did you validate your code?

What’s this:

*/ LIGHT GREEN a:visited {
color: #018A00;
}

There is no html tag called */ Light Green !!!

<*/ Light Green><a href="#">Link</a></*/ Light Green>

I assume you meant this:

/* LIGHT GREEN */
a:visited {
	color: #018A00;
}

You made loads of errors like that :slight_smile: …and while on the subject of comments this is invalid and will break things also.

<!--
======= BORDER-SPACING is the CSS equivalent of TABLE cellspacing =======
-->

Don’t use html comments inside a css file. Use only well formed css comments /* well formed css comments */

Also it is generally accepted as best practice to keep the property and values in lower case and not mix them as you have done here.

P {
	margin-TOP: 0px;
	margin-BOTTOM: 0px;
	margin-LEFT: 0px;
	margin-RIGHT: 0px;
}

That is very messy and hard to read so keep them all lower case and only use uppercase in your class names when you need to (as in camelCase class names if you are using that format).

Also that rule is very verbose and should be written like this anyway.

p{margin:0;}

A saving in 75% of the code and easier to read at the same time.

Lets look at this rule next.

H2 {
	margin: 0px 0 10px 0;
}
.hours h2 {
	font-size: 1.5em;
	margin: 0;
	padding: .25em;
}

The H2 is in uppercase in the first rule yet you make it lowercase in the following rule. Although css is case insensitive for all matters under its control it is still sensible to keep all element selectors to lowercase (in xhtml the rules would not be applied unless the case matched anyway).

Consistency is the key :slight_smile:

Also look at your margin rules again.

margin: 0px 0 10px 0;

Hmm why do you think it important that the first zero has the px unit but not the second a fourth zeros? Again css doesn’t mind if you add px to zero units (where padding/margin/dimensions are concerned) but it would be sensible to do one or the other. I tend to leave units off zero margins and padding.

e.g.

margin: 0 0 10px;

Note that numbers other than zero must have the unit defined.

More broken css here:

*/ Defining the header's background and border(s) padding: 10px;

That rule will not work because of the malformed comments (I won’t mention this again but there are a number of them in the page).

Never ever do this.:slight_smile:

It’s just as bad as using multiple breaks. I don’t understand why coders are so averse to adding a class to the element concerned and giving the element the exact margin/padding it needs rather than trying to guess that an empty p will be recognised or that multiple breaks will be implemented with some magic height that no one knows how to control. (In older doctypes and browsers multiple breaks were ignored anyway).

Just add a class to that p tag and give it the margin-bottom it deserves without abusing the markup or using extra elements. HTML Elements should not be used for the visual appearance they seem to impart. CSS is quite capable of handling the visual appearance whatever the mark up. The html mark up should be the correct semantic mark up for the job in hand.

Last one before I go and wash my hands :slight_smile:

<td bgcolor="#ECFFE1">12-8</td>

Presentational attributes were deprecated in a galaxy far away a long, long, long time ago.:slight_smile: Never use them again.

Use a class or style by some other css method.

So to answer your question I think you need to re-code the whole thing using an html table as this looks like tabular data and exactly the job for an html table. We can of course style it to look much like you have but I will wait before coding as I don’t want to waste time on something that you would not be prepared to use. Indeed you may disagree with me and think that this is not tabular data as these things are debatable. In my opinion if it looks like a table and has rows and columns that relate to each other then it is indeed a table:)

5 Likes

Questions concerning the library columns?

How many library columns are there going to be? You show 4 library columns but is this a dynamic number and could it be any number from 1 - 100 for example? This would be important in deciding which approach to take.

If there are more than 4 columns then how do the browsers need to handle multiple columns? Does the browser wrap a column to a new line and if so how are the days of the week supposed to follow? Or do the columns just keep stretching sideways in a scrollable div of sorts?

If the columns are to wrap to new lines depending on the width of the browser then it would make sense for the days of the week to be included in each column by default and unnecessary as an element on its own. Each column could then be a inline-table on its own merit.

How do you envisage the data being displayed on smaller windows or mobiles?

Until you have logical answers to the above then coding can’t really begin as the html/css code used needs to be dictated explicitly by the data that needs to be handled.

Planning ahead is also the key to consistency :slight_smile:

3 Likes

 
…and this…

<meta content="text/html charset=UTF-8 http-equiv=Content-Type">

…should be…

<meta content="text/html charset=UTF-8" http-equiv="Content-Type">

coothead

4 Likes