Question

I have an heavily customized theme based on twentythirteen. All the customized parts do not scale well with the other responsive parts of the layout. If I disable the customizations, the layout behaves well. I need to change the customized parts to make them responsive, but I don't know what I should change to make them behave in the right way.

I paste two examples of non-responsive customizations that I need to fix:

<section class="image-menu">
    <div>
    <ul id="image-menu-container" class="btn-group">
    <li class="btn"><a href="<?php echo esc_url( home_url( '/' ) ); ?>/lorem/ipsum/"><img src="<?php echo esc_url( home_url( '/' ) ); ?>/wp-content/themes/Aenean/images/phasellus_01.jpg" alt="" width="170" height="106" border="0" /><div>Ipsum</div></a></li>
    <li class="btn"><a href="<?php echo esc_url( home_url( '/' ) ); ?>/lorem/dolor/"><img src="<?php echo esc_url( home_url( '/' ) ); ?>/wp-content/themes/Aenean/images/phasellus_02.jpg" alt="" width="170" height="106" border="0" /><div>Dolor</div></a></li>
    <li class="btn"><a href="<?php echo esc_url( home_url( '/' ) ); ?>/lorem/sit-amet/"><img src="<?php echo esc_url( home_url( '/' ) ); ?>/wp-content/themes/Aenean/images/phasellus_03.jpg" alt="" width="170" height="106" border="0" /><div>Sit Amet</div></a></li>
    <li class="btn"><a href="<?php echo esc_url( home_url( '/' ) ); ?>/lorem/consectetur/"><img src="<?php echo esc_url( home_url( '/' ) ); ?>/wp-content/themes/Aenean/images/phasellus_04.jpg" alt="" width="170" height="106" border="0" /><div>Consectetur</div></a></li>
    <li class="btn"><a href="<?php echo esc_url( home_url( '/' ) ); ?>/lorem/adipiscing/"><img src="<?php echo esc_url( home_url( '/' ) ); ?>/wp-content/themes/Aenean/images/phasellus_05.jpg" alt="" width="170" height="106" border="0" /><div>Adipiscing </div></a></li>
    </ul>
    </div>
</section>

This is another example:

<section class="banner-slider">
    <div class="center-wrap">
    <div id="slides">
        <div class="slides_container" style="overflow: hidden; position: relative; display: block;">                      
            <div class="slides_control" style="position: relative; width: 300%; height: 33px; left: -960px;">       
                <div class="clearfix home-slider-post" id="slider-post-462" style="position: absolute; top: 0px; left: 960px; z-index: 0; width: 33.4%; height: auto; display: block;">
                    <h1 class="entry-title" style="color:white;"><?php the_title(); ?></h1>
                </div>
            </div><!-- END slider post -->
        </div><!-- END slides_container -->
    </div><!-- END center-wrap --> 
    </div>
<div class="shadow top"></div>
<div class="shadow bottom"></div>
<div class="tt-overlay"></div>
</section>  

Someone can give me at least some directions on how to make those responsive? The site is on localhost so I don't have an url I can give you.

Was it helpful?

Solution

You have to use css media queries to do that. Just remember, IE7 and 8 doesn't accept media queries and is not responsive. You can look at my answer on this issue here.

If you have a look at the twenty thirteen themes' style.css, you will see that media queries start at line 2575. It is this media queries that make your theme responsive. In you code you are using in-style css, which I strongly discourage. This will give you issues when making your theme responsive.

Take for example this line

<div class="slides_container" style="overflow: hidden; position: relative; display: block;"> 

You should write your html as follows

<div class="slides_container">

You should move your styles to your style.css like this

.slides_container {
    overflow: hidden; 
    position: relative; 
    display: block;
}

Say you want to make this responsive, and you need position: fixed for smaller screens, do something like this

.slides_container {
    overflow: hidden; 
    position: fixed; 
    display: block;
}

Now you need position: relative; and font-size: 20px;at screen size 650px and bigger. This is where the media queries come in. Just a point of note, you don't need to copy all the elements into your media query if they don't change values, just add elements that are changing. You can also add other values that is not specified generally.

You style when then looks like this

 @media (min-width: 650px) {             
   .slides_container {
       font-size: 20px; 
       position: relative; 
   }
}

You can have multiple queries for the same element, as long as your screen sizes differ. For instance, you need the font size to change to 24px for screens bigger than 1200px. You will then do something like this

 @media (min-width: 1200px) {             
   .slides_container {
       font-size: 24px; 
   }
}

Note that you again don't have to set element position as it is not changing for screens bigger that 1200px

I hope this will help to achieve your goal.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top