简体   繁体   English

我的横幅图片未使用“@media (min-width: 320px) and (max-width:767px)”显示

[英]My banner picture is not displaying using “@media (min-width: 320px) and (max-width:767px)”

I have a carousel div that should be displayed for tablet mode and desktop mode.我有一个轮播 div,应该在平板电脑模式和桌面模式下显示。 I have also a div named header-mobile-banner that should be displayed for mobile mode.我还有一个名为 header-mobile-banner 的 div,应该在移动模式下显示。 The header-mobile-banner will be hidden for the tablet mode and desktop mode.Then my carousel will be hidden in mobile mode.在平板模式和桌面模式下,header-mobile-banner 将被隐藏。然后我的轮播将在移动模式下隐藏。 The problem is that the header-mobile-banner is not displaying in my mobile mode, i dont know why.问题是标题移动横幅没有在我的移动模式下显示,我不知道为什么。 Here is my code: Partial css code:这是我的代码:部分 css 代码:

/*general*/
.font-Awesome{font-family: 'fontawesomeregular';}
.font-GaramondPremierePro{font-family: 'Garamond Premiere Pro';}
.font-CormorantGaramond{font-family: 'Cormorant Garamond', serif;}
.font-GreatVibes{font-family: 'Great Vibes', cursive;}
.white{color: #ffffff;}

/*Header by order*/
.header-banner{ width:100%; height:663.31px; padding:0px !important; top:0; }
.header-banner-graydiv{background-color: black; background: rgba(0,0,0,0.5); position: absolute; top: 0%; left: 0; right: 0; vertical-align: middle; text-align: center; horizontal-align: middle; margin: 14% 15% 9% 15%; bottom: 0%; padding: 4%;}

.carousel-inner .header-banner-graydiv h3{font-size: 50px;}
.carousel-inner .header-banner-graydiv h1{font-size:92px;}
.carousel-inner .header-banner-graydiv h4{font-size: 39px;margin-top: -2%;margin-bottom:4%; }
.carousel-inner .header-banner-graydiv p{font-size:20px;}
.header-subscribe-section {background-color:#ad1f34; height:99.27px; width:100%}
.header-p-latestmenus{font-size:20px; letter-spacing:0.5px;}
.header-p-subscribe{font-size:28px; letter-spacing:0.5px;}
.header-btsubscribe{border-radius:4px; background-color:#831024; color:white; width:134.55px; height:44.19685px; width:146.19685px; border:none;font-size:18px;}
.header-textboxemail{width: 286.779527559px;height: 46.19685px;font-size: 17px;border: 0;margin-left: -49%;margin-top: 7%;}
.header-subscribe-section p{padding: 4% 15%;}
.header-mobile-graydiv{display: none;}

/*responsiveness lowest to greatest*/
/*mobile*/
@media (min-width: 320px) and (max-width:767px)
{   
#myCarousel{display: none;}
.carousel{display: none;}
.header-mobile-banner{ width:100%; height:663.31px; padding:0px; top:0; background-image: url("../img/head_banner.jpg"); background-repeat: no-repeat;background-size: contain; }
.header-mobile-graydiv{ background-color: black; height:300px; background: rgba(0,0,0,0.5); position: absolute; top: 0%; left: 0; right: 0; vertical-align: middle; text-align: center; horizontal-align: middle;  bottom: 0%; }
.header-mobile-graydiv h3{font-size: 50px;}
.header-mobile-graydiv h1{font-size: 92px;}
.header-mobile-graydiv h4{font-size: 39px;}
.header-mobile-graydiv p{font-size: 20px;}
.header-mobile-banner{display: none;}
}
/*tablet*/
@media (min-width: 768px) and (max-width:800px)
{   
.header-mobile-banner{display: none;}
.header-banner-graydiv{margin: 4% 11% 8% 11%; bottom: 0%; padding:2%;}
.carousel-inner .header-banner-graydiv h3{font-size: 40px;}
.carousel-inner .header-banner-graydiv h1{font-size:68px;}
.carousel-inner .header-banner-graydiv h4{font-size: 30px;margin-top: -2%;margin-bottom:4%; }
.carousel-inner .header-banner-graydiv p{font-size:15px;}
}
@media (min-width: 801px) and (max-width:991px)
{   
.header-mobile-banner{display: none;}
.header-banner-graydiv{margin: 4% 11% 8% 11%; bottom: 0%; padding-top:6%;}
.carousel-inner .header-banner-graydiv h3{font-size: 45px;}
.carousel-inner .header-banner-graydiv h1{font-size:80px;}
.carousel-inner .header-banner-graydiv h4{font-size: 35px;margin-top: -2%;margin-bottom:4%; }
.carousel-inner .header-banner-graydiv p{font-size:17px;}
}

/*desktop up to the size of my screen*/
@media (min-width: 992px) and (max-width:1365px)
{   
.header-mobile-banner{display: none;}
}
/*huge*/
@media (max-width: 1920px)
{   
.header-mobile-banner{display: none;}
.header-banner{ width:100%; height:663.31px; padding:0px !important; top:0; }
}

Partial html code:部分html代码:

<!--header-->
    <div id="header">
            <div id="myCarousel" class="carousel slide" data-ride="carousel">
                  <!-- Indicators -->
                  <ol class="carousel-indicators">
                    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                    <li data-target="#myCarousel" data-slide-to="1"></li>
                    <li data-target="#myCarousel" data-slide-to="2"></li>
                  </ol>
                 <!-- Wrapper for slides -->
                <div class="carousel-inner">
                    <div class="item active">
                        <img src="img/head_banner.jpg" class="header-banner" >
                        <div class="header-banner-graydiv">
                             <h3 class="font-GaramondPremierePro white">WELCOME TO</h3>
                             <h1 class="font-GreatVibes white">Your Restaurant Name</h1>
                             <h4 class="font-GaramondPremierePro white">FOOD &amp RESTAURANT</h4>
                             <p class="font-CormorantGaramond white">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod <br> tempor incididunt ut labore et dolore magna. aliqua. Ut enim ad minim </p>
                        </div>
                    </div>
                    <div class="item">
                        <img src="img/sample_carousel1.jpg" class="header-banner" >
                        <div class="header-banner-graydiv">
                             <h3 class="font-GaramondPremierePro white">WELCOME TO</h3>
                             <h1 class="font-GreatVibes white">Your Restaurant Name</h1>
                             <h4 class="font-GaramondPremierePro white">FOOD &amp RESTAURANT</h4>
                             <p class="font-CormorantGaramond white">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod <br> tempor incididunt ut labore et dolore magna. aliqua. Ut enim ad minim </p>
                        </div>
                    </div>

                    <div class="item">
                          <img src="img/sample_carousel2.jpg" class="header-banner" >
                            <div class="header-banner-graydiv">
                                 <h3 class="font-GaramondPremierePro white">WELCOME TO</h3>
                                 <h1 class="font-GreatVibes white">Your Restaurant Name</h1>
                                 <h4 class="font-GaramondPremierePro white">FOOD &amp RESTAURANT</h4>
                                 <p class="font-CormorantGaramond white">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod <br> tempor incididunt ut labore et dolore magna. aliqua. Ut enim ad minim </p>
                            </div>
                    </div>
                </div>
                  <!-- Left and right controls -->
                          <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                            <span class="glyphicon glyphicon-chevron-left"></span>
                            <span class="sr-only">Previous</span>
                          </a>
                          <a class="right carousel-control" href="#myCarousel" data-slide="next">
                            <span class="glyphicon glyphicon-chevron-right"></span>
                            <span class="sr-only">Next</span>
                          </a>
            </div>
            <div class="header-mobile-banner" >
                    <div class="header-mobile-graydiv">
                         <h3 class="font-GaramondPremierePro white">WELCOME TO</h3>
                         <h1 class="font-GreatVibes white">Your Restaurant Name</h1>
                         <h4 class="font-GaramondPremierePro white">FOOD &amp RESTAURANT</h4>
                         <p class="font-CormorantGaramond white">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod <br> tempor incididunt ut labore et dolore magna. aliqua. Ut enim ad minim </p>
                    </div>
            </div>
            <div class="container-fluid header-subscribe-section">
                <div class="container">
                    <div class="row">
                        <div class="col-md-7 col-xs-12">
                            <p>
                                <span class="header-p-latestmenus font-Awesome white">Get our latest menus in your inbox.</span>
                                <span class="header-p-subscribe font-GreatVibes white">Subscribe Now!</span>
                            </p>
                        </div>
                        <div class="col-md-5 col-xs-12">
                            <input type="text" name="lname" class="header-textboxemail font-Awesome white" placeholder="Email Address">
                            <button type="button" class="header-btsubscribe font-GaramondPremierePro">SUBSCRIBE</button>
                        </div>
                    </div>
                </div>
            </div>
    </div>
    <!--end of header-->

Remove移除

    .header-mobile-banner{display: none;}

from the last line in从最后一行开始

   @media (min-width: 320px) and (max-width:767px)

If you are using bootstrap then you can use this helper class如果您使用的是引导程序,那么您可以使用此辅助类

https://getbootstrap.com/docs/3.3/css/#responsive-utilities-classes https://getbootstrap.com/docs/3.3/css/#responsive-utilities-classes

Hope this will help you.希望这会帮助你。 You do not need to write extra css for do that您不需要为此编写额外的 css

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 @media(最大宽度:767像素){/ * content * /}不起作用 - @media (max-width: 767px) { /*content*/} does not work 对象标签不适用于@media(最大宽度:767像素) - Object tag is not working on @media (max-width: 767px) 最大宽度设置为767px时的媒体查询 - Media query when max-width is set to 767px 如何使用媒体查询的最大宽度:首先使用Bootstrap 4移动版的767px - How to use media query for max-width: 767px using Bootstrap 4 mobile first 显示:块; 对@media没有影响(最大宽度:320像素) - display: block; has no effect on @media (max-width: 320px) 绝对定位的子项应与其父项的大小相同,因为我在 320 像素和 767 像素屏幕宽度之间调整屏幕大小 - Absolute positioned child should be at the same size as its parent as im resizing the screen between 320px and 767px screen width 媒体查询最大宽度320px问题 - media queries max width 320px issue 文字在@media屏幕上居中对齐,并且(min-width:992px)和(max-width:1199px) - text not aligns to centers on @media screen and (min-width:992px) and (max-width:1199px) 仅屏幕和(最小宽度:0px)和(最大宽度:327px)不起作用 - only screen and (min-width: 0px) and (max-width: 327px) not work @media(320px)无法与我的列配合使用,以使其宽度为100% - @media (320px) not working with my columns to make them 100% width
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM