473,786 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

overflow hidden fails when its container has percentage height

I have an elastic layout site. In it I am trying to use a three tiered image as a three state button. The container for this button is limited to the height of one state/tier of the button and has overflow: hidden; applied. This works fine to mask the unseen states/tiers --as long as the height for the container is set in pixels.

!!! My problem !!! As soon as I set the height of the masking container (#paper) as a percentage, to keep the layout elastic, overflow: hidden; fails expanding the container to show all the states/tiers.

I have tried setting all other parent tags with height: 100%; and/or max-height: in em's proportionate to the max-width of my wrap. No luck, no matter what I do this set-up breaks as long as #paper's height is %. Am I breaking some unspoken rule? None of my searching or research into overflow: hidden; is of any help whatsoever.

Expand|Select|Wrap|Line Numbers
  1.  
  2. HTML---
  3. <div id="wrap"><img class="full" src="img/home-bckgrnd.jpg" alt="" title="">
  4.  
  5. <div id="header" class="group">
  6.     <div id="logo">
  7.         <a href="#">HUEY CROWLEY</a>
  8.     </div>
  9.  
  10.     <ul id="nav">
  11.         <li id="paper"><a href="pages/paper.html"><img class="full" src="img/paper-link.jpg" alt="" title=""><span class="alt">PAPER</span></a></li>
  12.         <li id="paint"><a href="pages/paint.html"><span class="alt">PAINT</span></a></li>
  13.         <li id="junk-drawer"><a href="pages/junk-drawer.html"><span class="alt">JUNK DRAWER</span></a></li>
  14.         <li id="store"><a href="pages/store.html"><span class="alt">STORE</span></a></li>
  15.         <li id="about"><a href="pages/about.html"><span class="alt">BIO/CV</span></a></li>
  16.         <li id="contact"><a href="mailto:contact@hueycrowley.com"><span class="alt">CONTACT</span></a></li>
  17.     </ul>
  18. </div> <!-- /header -->
  19.  
  20.  
  21. CSS---
  22. body {
  23.     font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  24.     color: #444;
  25.     font-size: 62.5%; /* takes 16px (default size for ‘medium’ text in all modern browsers) down to 10px, a nice round number for quikly calculating relative parent/child font-sizes in the time-sensetive real world.
  26.                         From now on it’s easy to think in pixels but still set sizes in terms of ems: 1em is 10px, 0.8em is 8px, 1.6em is 16px, etc.  */
  27.     background: #000;
  28. }
  29. #wrap {
  30.     margin: 0 auto;
  31.     max-width: 192em;  /* = 1920px; */
  32.     /* height: 100%; */
  33.     /* max-height: 152em;  = 1520px; */
  34. }
  35.  
  36. #header {
  37.     position: absolute;
  38.     width: 100%;
  39.     height: 100%;
  40.     top: 0;
  41. }
  42. #nav {
  43.     /* width: 100%;
  44.     height: 100%;
  45.     border: 1px solid pink; */
  46. }
  47. a .alt { /* text hidden from sight but safe for screen readers, only breaks if user prefs CSS=on images=off */
  48.     /* display: block;
  49.     width: 0;
  50.     height: 0;
  51.     overflow: hidden; */
  52. }
  53.  
  54. /* creates sized opening for portion of 3tiered paper-link button to show through */
  55. /* percentages % used to expand/contract buttons with the entire elastic layout */
  56. #paper {
  57.     display: block;
  58.     /* width: 15%; result of-- 289px-this container/1920px-context of container width --#wrap-- it scales in = .15 */
  59.     width: 289px;
  60.     /* width: 20.25%; */ /* what is the context width if this is the % which displays full size ?  */
  61.     /* height: 6%;  result of-- 95px-this container/1520px-context of container height --#wrap-- it scales in = .06 */
  62.     height: 95px;
  63.     overflow: hidden;
  64.     border: 1px solid red;
  65. }
  66. /* button starts showing only top tier and returns to top tier after being activated*/
  67. #paper a img, a:visited img {
  68.     position: relative;
  69.     margin: 0;
  70. }
  71. /* button moves up showing only middle tier */
  72. #paper a:hover img {
  73.      /* top: -6%; result of-- 96px-this container/1520px-context of container height --#wrap-- it scales in = .06 */
  74.     top: -96px;
  75.     /* top: -101.25%; */
  76. }
  77. /* button moves up showing only bottom tier */
  78. #paper a:active img {
  79.      /* top: -13%; result of-- 190px-this container/1520px-context of container height --#wrap-- it scales in = .13 */
  80.     top: -190px;
  81.     /* top: -195.25%; */
  82. }
  83.  
  84.  
Oct 19 '10 #1
4 1703
Death Slaught
1,137 Top Contributor
I don't have time to look at it right now, but absolutely positioned elements are removed from the normal flow of the page. Also, when using emphasis it adapts automatically to the font. Take a look at this. I'll look at this more when I have time.


Thanks, Death
Oct 19 '10 #2
Hey thanks for the feedback.

I have been trying to make this work with a horizontal 3-image button too, thinking that if I could alleviate the vertical overflow (because the elastic layout is based widths) everything would fall into place. Not so. I'm having the same breaking of overflow: hidden; in the horizontal.

I did catch that absolute positioned div separating the container with overflow from basing its relative measurement on the em sized div#wrap. Once I switched it to relative positioning #paper was able to have its width sized relatively. In this situation #paper overflow worked ok as long as the image inside it was fixed dimensions. As soon as I added a class to the image causing it to scale to 100% of its container the overflow failed.

I'm beginning to think trying to constrain a container to a % of an elastic layout while using overflow: hidden; on it in trying to toggle a 3part image, which should also be scalable with the layout, is simply not possible.
Oct 19 '10 #3
Death Slaught
1,137 Top Contributor
I'm not going to be able to mess with this today - three projects plus school is taking up all of my time. Try changing the width from emphasis to pixels. If I'm not mistaken the width of the entire page is increased?

Also, the width you want should ultimately be in pixels. If I'm not mistaken, and someone please correct me if I'm wrong, emphasis is creating the width based on your font's size. In this case 62.5%, and changes depending on your browser and OS - each display fonts differently. The max-width property does not include padding, borders, or margin.


Regards, Death
Oct 19 '10 #4
Hey Death, & anyone else who should happen to come across this post,
- Totally possible and I figured it out.

Basically you have to size the sliding buttons' containers as a % of the whole ("body" is the context in this case)then, since there are 3 states, the button image has to be given a CSS rule displaying it at 300%. The reason being, the other (background) images here already scale with the layout by having a max-width of 100%. They will expand their container to its max, but since the button image container is a % of the body already, assigning the button images to the max-width 100% rule (.full) caused the image to scale DOWN, filling the % container with ALL of the button but in that lesser space. So overflow didn't even come into play. Once I figured that out I gave the button images %'s 3x that 100 and... it forced the overflow to work showing only one state of the button at a time (moving it left 1/3 by negative margins)with :hover and :active.

Breaks what might be considered a prime-directive of image-sizing for the web but in this case I think it's okay since the button file resolutions are high enough to keep them from looking like garbage.

Anyhow, it works in all major browsers. I'll go ahead and post the site address here once it is done so anyone who is REALLY interested or REALLY bored will have a chance to check out what the rambling above actually does.

-TREVOR
Oct 23 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
14664
by: Charles Blaquière | last post by:
As part of my explorations in liquid design, I'm exploring ways to use the overflow: hidden property -- when browser windows become too narrow, I want (some) images to get cropped rather than have the layout break up. In some cases, losing parts of images can be an interesting option. http://www.hebig.org/blog/titlepic.php was the first example I found, and it's quite nifty. His image works well when progressively cropped from the right,...
6
19411
by: Kai Grossjohann | last post by:
I have a frame which is supposed to contain a list of links. The clickable area of each link comprises a picture followed by some text. I want the text to be cut at the right hand side when the user resizes the frame to be "too narrow". Right now, the source for that frame looks like this: <table border="1" width="100%"> <tr style="background-color:#C0C0C0">
8
7418
by: Vic | last post by:
I've managed to achieve the effect I wanted in IE6 - although I had to use an experession to set the vertical height of a div (I want it to have an overflow and scroll) but I can't work out a way to duplicate the effect in Mozilla/Firefox the code is here: http://www.fogcat.co.uk/example/example.html Can anyone point me in the right direction - or at least tell me if it is or isn't possible to get the same functionality in Firefox
22
6976
by: Les Juby | last post by:
I am trying to adjust the window/table size of a website (www.worklaw.co.za) which has made use of DIV tags with its settings embedded in an CSS file. The client wants its width and height to adjust according to dynamic screen size, and I have been able to adjust the width to a percentage value which works fine. But if I try do the same with the height it shows some very strange results squashing the field to display about 3 lines.
1
2104
by: CB | last post by:
Using C# in .Net 2003, DataSet.ReadXml fails when a percentage (%) sign is in the filename followed by 2 hex characters. Seems that the % sign is likely encoding the following 2 hex characters. So c:\test%ab.xml fails for ReadXml since %ab is interpreted as 171 and c:\test171.xml does not exist. There is no problem with c:\test%mn.xml because "mn" is not a hex code. If I replace the % sign with %25 (25hex = 37dec = ascii code for %),...
3
2299
by: bryanrite | last post by:
I'm trying to set up a page with a static block on the left and variable on the right, it works as expected, but when i add an image, or google ad, in firefox it behaves as expected, but IE drops the div. Anyone have any ideas? http://footstops.dev01.alkaloid.net/test.php Any help would be greatly appreciated!
5
6900
by: Christopher Night | last post by:
I'm making a Javascript program that uses overflow:hidden on a containing div to crop an image. This page (temporarily) shows an example of what I mean: http://www.people.fas.harvard.edu/~night/crossroads/ The relevant markup is: <div style="overflow:hidden; width: 238px; height:47px; border: thin yellow solid;">
2
15569
by: esteuart | last post by:
I need to get the right combination for a div to clip any text inside and allow vertical alignment. I only have this problem in FireFox. I have 3 divs nested within each other. The outer div has display of table, the first inner div has display of table-cell and the inner-most div has the text. The outer div has a set width and height. So here's the problem: Without the inner divs having a width and height set, the overflow:hidden doesn't...
4
2869
by: zzpat | last post by:
I have a box element that uses overflow: hidden and I want a link which at the bottom of the element to be visible. I can't make the link visible. Obviously I'm having problems so I was wondering if there's anything other than overflow : hidden that will give me an absolute 'height' and make the link visible. Pat
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3669
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.