prevent menu elements from overlapping when window resized

I have a simple design shown here:

<style>
.section {
      clear: both;
      padding: 0px;
      margin: 0px;
}
.col {
      display: block;
      float:left;
      margin: 1% 0 1% 0;
}
.span1 {
      width: 16.1%;
}
@media only screen and (max-width: 480px) {
      .col { margin: 1% 0 1% 0%;}
      .span1 { width: 100%; }
}
</style>
<div class="section group">
      <div class="col span1">
      ElementOne
      </div>
      <div class="col span1">
      ElementTwo
      </div>
      <div class="col span1">
      LongerElementThree
      </div>
      <div class="col span1">
      ElementFour
      </div>
      <div class="col span1">
      ElementFive
      </div>
      <div class="col span1">
      ElementSix
      </div>
</div>

See how the LongerElementThree overlaps before the elements stack?
So I want to know how to prevent this.
Thanks
LVL 25
dgrafxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

InsoftserviceCommented:
Please provide the screen shot of overlapping as at my end there is no such overlapping.
0
dgrafxAuthor Commented:
See how the longer element text gets overlapped?
menu-overlap.png
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
That is because your columns are too narrow for the amount of text.  You can either break up the words with spaces which will make them wrap or you can make the columns larger.  You have to account for multiple breaks for phone, tablet and desktop.  Why try and reinvent the wheel.  Try using bootstrap or foundation for your responsive grid.  They have all of this figured out.

Check out your html with bootstrap accounting for 3 different screen sizes. http://jsbin.com/kotufu/1/edit?output No overlap. Different size columns for each viewport.

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>

</head>
<body>
<div class="row">
      <div class="col-xs-6 col-sm-4 col-md-2">
      ElementOne
      </div>
      <div class="col-xs-6 col-sm-4 col-md-2">
      ElementTwo
      </div>
      <div class="col-xs-6 col-sm-4 col-md-2">
      LongerElementThree
      </div>
      <div class="col-xs-6 col-sm-4 col-md-2">
      ElementFour
      </div>
      <div class="col-xs-6 col-sm-4 col-md-2">
      ElementFive
      </div>
      <div class="col-xs-6 col-sm-4 col-md-2">
      ElementSix
      </div>
</div>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

dgrafxAuthor Commented:
ok right - your jsbin example is what I was trying for ...
thanks for the words - i will look into it!

thanks
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Your welcome!   Once you get your head wrapped around the basic classes you will kick yourself for not doing this sooner.    

I meant to provide the link http://getbootstrap.com/  The key is the grid http://getbootstrap.com/css/#grid where columns are wrapped in a row class then col-xs-1, col-sm-1, col-md-1 or col-lg-1 where the "1" can be any number from 1 to 12 as there are 12 columns.  If you want 1 column for the phone, 3 columns for ipad and 6 columns for desktop you would use

<div class="row">
<div class="col-xs-12 col-sm-4 col-md-2"> stuff </div>
<div class="col-xs-12 col-sm-4 col-md-2"> stuff </div>
<div class="col-xs-12 col-sm-4 col-md-2"> stuff </div>
<div class="col-xs-12 col-sm-4 col-md-2"> stuff </div>
<div class="col-xs-12 col-sm-4 col-md-2"> stuff </div>
<div class="col-xs-12 col-sm-4 col-md-2"> stuff </div>
</div>

Open in new window

0
dgrafxAuthor Commented:
Thanks Scott
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.