Forum Moderators: not2easy

Message Too Old, No Replies

Section height - responsive

         

flamingoezz

6:18 pm on Feb 24, 2015 (gmt 0)

10+ Year Member



I have a wordpress theme I'm working with and trying to make a section into a full-width image with parallax. The theme doesn't seem very well written so I'm adding some custom CSS to try to get it working.

I got the scrolling effect to work as I wanted but the height of the section doesn't adapt when viewed on a phone -- image becomes 100px high, but section is still 500px for example. I was looking into 'vh', but haven't had luck with it as of yet.

Is this the right direction?

not2easy

6:30 pm on Feb 24, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You don't mention whether this is a html5 theme or a xhtml theme nor the CSS version you are editing.
In General, you can try
height: auto;

For the container.

flamingoezz

7:15 pm on Feb 24, 2015 (gmt 0)

10+ Year Member



html5 & css3

i dont think height:auto will work because i am using a background on a section (with no other content). I think I need to set the height relative to something else, like the browser height..unless there is another way i should be doing this.

not2easy

7:49 pm on Feb 24, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If you use px for the width, the height can't adapt, it will be the height of the image unless specified otherwise. If you want responsive widths to adjust to the width and height of the image, you need to constrain the container's width in a responsive measurement such as % or em.

If this theme is using bootstrap, look at the various widths in the classes and apply @media to the container. Height based on browsers doesn't work well, you would need to determine the screen size and orientation and that is just too much a moving target to work well.

There are lots of great css people around here, be patient and someone much better versed in iframe usage will probably stop by.

flamingoezz

8:17 pm on Feb 24, 2015 (gmt 0)

10+ Year Member



If I don't set a height on the section, since there is no content -- it'll be as if the background doesn't exist.

Using height:100% shows nothing still -- probably to do with parent items(?)setup via the theme I'm thinking. I can't use px value because it'll not adapt to mobile. Using vh doesn't get the proportion right, but is somewhat closer. Maybe this will get me moving in the right direction.
How do you normally set a height for the background when doing parallax?