1 Replies - 417 Views - Last Post: 02 May 2016 - 03:59 PM

#1 dday9   User is offline

  • D.I.C Regular

Reputation: 95
  • View blog
  • Posts: 495
  • Joined: 17-April 13

event for when oversized

Posted 02 May 2016 - 03:18 PM

I don't know if this is a CSS question or a JQuery question.

Basically I am using a traditional means of creating a horizontal navigation bar which consists of:
<!-- HTML -->
<ul class="navigation">
  <li>
    <a href="#">Monday</a>
  </li>
  <li>
    <a href="#">Tuesday</a>
  </li>
  <li>
    <a href="#">Wednesday</a>
  </li>
  <li>
    <a href="#">Thursday</a>
  </li>
  <li>
    <a href="#">Friday</a>
  </li>
</ul>

/* CSS */
ul {
  list-style-type: none;
  margin: 2em 0;
}

.navigation {
  padding:0;
  text-align: center;
}

.navigation li {
  display: inline;
}

.navigation li a {
  background-color: #4CAF50;
  border: none;
  border-radius: .5em;
  color: #fffff0;
  padding: 1em 2em;
  text-align: center;
  text-decoration: none;
}

.navigation li a:hover {
  background-color: #fac943;
  color: #880085;
  text-decoration: underline;
}


Typically I'd use CSS3's flexbox but I am wanting to go the traditional route for older browsers.

Right now I have the <body>'s max-width to 50% and margin set to auto and using a media query for when the max-width is 1120px and then changing the max-width to 75% and also when the max-width is 740px I change the max-width to 100% and the margin to 0. The reason I do this is for the <li> elements to stay inline and not start to overflow, however I find that this solution is not very good. It works on some screens but not all...

I'm using JQuery to toggle the visibility of some other <ul> elements so my thought is to just display the navigation <ul> to display vertically when it starts to overflow, so is there an event for when the overflow starts to occur?

Is This A Good Question/Topic? 0
  • +

Replies To: event for when oversized

#2 astonecipher   User is offline

  • Enterprise Software Architect
  • member icon

Reputation: 3215
  • View blog
  • Posts: 12,098
  • Joined: 03-December 12

Re: event for when oversized

Posted 02 May 2016 - 03:59 PM

Not that I know of. You can use resize, for when the window size changes. But going so granular to say, when this element, I think that you would have to roll your own on that one.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1