简体   繁体   中英

Four images on the page will not resize when the window is resized

I am trying to get the four images found in the class slide to re-size when the window is re-sized. Currently the images will slide over when the window gets smaller but they never get smaller. I believe that this is a bootstrap issue specifically with col-sm-3 and row classes. You can find and fork my code at https://github.com/mcontado/madison

<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <title>Eleven Madison Park Resturant</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
    <script src="http://malsup.github.io/min/jquery.cycle.all.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="shortcut icon" href="https://media-cdn.getbento.com/accounts/102da05919be0726cec2e6365172199c/media/accounts/media/hf1OSSqmQByRUTiQbhxg_favicon.ico" type="image/x-icon"><!-- this adds the favicon -->
    <script type="text/javascript" src="js/form.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link type="text/css" rel="stylesheet" href="css/style.css"/>
</head>

<body>
    <div class="shell container-fluid clearfix">
        <header class="site-header pull-right" role="banner">
            <a href="http://www.elevenmadisonpark.com/">
                <img src="photo/logo_top.png">
            </a>
        </header>

        <section class="wrapper">
                <div class="row hidden-xs">
                    <div class="slide slider1 col-xs-3">
                        <img id="01" src="photo/0a.jpe">
                        <img id="02" src="photo/1a.jpe">
                        <img id="03" src="photo/2a.jpe">
                        <img id="04" src="photo/3a.jpe">
                    </div>

                    <div class="slide slider2 col-xs-3">
                        <img id="11" src="photo/0b.jpe">
                        <img id="12" src="photo/1b.jpe">
                        <img id="13" src="photo/2b.jpe">
                        <img id="14" src="photo/3b.jpe">
                    </div>

                    <div class="slide slider3 col-xs-3">
                        <img id="21" src="photo/0c.jpe">
                        <img id="22" src="photo/1c.jpe">
                        <img id="23" src="photo/2c.jpe">
                        <img id="24" src="photo/3c.jpe">
                    </div>

                    <div class="slide slider4 col-xs-3">
                        <img id="31" src="photo/0d.jpe">
                        <img id="32" src="photo/1d.jpe">
                        <img id="33" src="photo/2d.jpe">
                        <img id="34" src="photo/3d.jpe">
                    </div>
                </div>
        </section>
                <div class="navigation">
                    <nav>
                        <ul class="nav-stacked">
                            <li>
                                <a href="">MENUS</a>
                            </li>
                            <li>
                                <a href="">RESERVATIONS</a>
                            </li>
                            <li>
                                <a href="">PEOPLE</a>
                            </li>
                            <li>
                                <a href="">ACCOLADES</a>
                            </li>
                            <li>
                                <a href="">PRIVATE DINING</a>
                            </li>
                            <li>
                                <a href="">COOKBOOKS</a>
                            </li>
                            <li>
                                <a href="">COLLABORATIONS</a>
                            </li>
                            <li>
                                <a href="">CONTACT</a>
                            </li>
                        </ul>
                    </nav>
                    <div class="bottom-logo hidden-xs">
                        <a href="http://www.relaischateaux.com/" target="blank">
                            <img src="http://assets-cdn.getbento.com/assets/elevenmadisonpark/!362b28668884299914b932bd37a50b983c5e7c90ae93b!/img/logo_relais.png" class="something" alt="Relais & Chateaux">
                        </a>
                    </div>
                </div>

        <!-- </section> -->


        <footer class="visible-xs">
            <p>
                11 Madison Ave, New York, New York 10010
                <br>
                212.889.0905 
                <a href="mailto:info@elevinmadisonpark.com">info@elevenmadisonpark.com</a>
            </p>    
        </footer>

    </div>
</body>

Here is the CSS

body {
background-color: #1d1d1d;
font-family: "Helvetica Neue", helvetica, arial, sans-serif;
}

header img {
float: right;
margin: 20px 16px 26px 0;
}

.shell {
margin: 0 auto;
/*position: relative;*/
/*text-align: left;*/
width: 963px; /*this fixed pic spacing*/
}

   .wrapper {
clear: both;
}

.slide {
float: left;
height: 335px;
margin-right: 1px;
overflow: hidden;
position: relative;
width: 240px;
}

.slider4 {
margin-right: 0;
}

a {
color: gray;
text-decoration: none;
}

a:hover {
color: white;
text-decoration: none;
}

ul {
list-style: none;
font-size: 1.5em;
}

li {
margin-bottom: -0.2em;
}

a img {
float: right;
}

.container-fluid {
padding-left: 0;
padding-right: 0;
}

.navigation {
clear: both;
}

footer {
clear: both;
margin-left: 3em;
}

p {
font-size: 1.5em;
line-height: 1.6em;
color: #b5b5b5;
}

nav {
float: left;
}

.row {
margin: 0 auto;
}

here is the javaScript

$(document).ready(function(){

$(".slide > img").fadeOut(0);

$('.slider2, .slider4').cycle({
      timeout: 8000,
    });

$('.slider1, .slider3').cycle({
        delay: 2000,
        timeout: 8000,
      });
});

You could try using "vh" instead o "px" (when stating the size of the images). That way the image changes size depending on the size of the window it is beeing displayed on, I belive.

You can read about vh and vw in here: http://snook.ca/archives/html_and_css/vm-vh-units

To use it you just need to put it in the img tag, or in a css style sheet that would affect that img as can be seen in the example: http://i.imgur.com/qE9vxER.png

For images, use percentages. That way, as you resize the page the image will resize with it to match the percentage you put in.

For example:

<img style="width:25%" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">

The above will behave differently than if the width were in px.

small jsbin example

set max-width to 100% for the img tag in your css. All your site images will re-size as the browser re-sizes. Also, give your width properties in percentages.

img {
    max-width: 100%;
}

.header-img {
    width: 67%;
}

Thanks,

Images in Bootstrap 3 can be made responsive-friendly via the addition of the .img-responsive class. This applies max-width: 100%;, height: auto; and display: block; to the image so that it scales nicely to the parent element.

<img src="..." class="img-responsive" alt="Responsive image">

So add this class to all your images to make it responsive.

<img id="01" class="img-responsive" src="photo/0a.jpe"> and so on... To all your img tags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM