响应WordPress功能框导致两个问题

时间:2014-04-21 19:42:03

标签: html css wordpress responsive-design

我在WordPress development site上创建了一个功能框。在一些帮助下,我使功能盒响应迅速,它几乎完成了。您可以在下面的屏幕截图enter image description here

中看到此功能框正确显示

但是,我有两个问题:

1)当我缩小浏览器窗口的大小时,导航栏会变为两行并覆盖我的功能框(如图所示)。我希望功能框在导航栏扩展时向下移动。

A screenshot of my expanded navar covering the feature box

2)在我的手机上,我的功能框中的红色条带超出了页面的宽度,导致导航栏显示不正确(如图所示)。我不希望红丝带扩展到导航栏的宽度之外。

Here you can see the red ribbon causing an issue with my site on a HTC One

我使用CSS和图片创建了导航栏。使用CSS,我创建了一个大的红色矩形,它扩展到我的功能框边缘之外。然后,我使用了红色三角形的图像,并将其放置在红色矩形下方。您可以通过查看"#text-4"来了解我是如何做到这一点的。在我的CSS中。

我的相关CSS是

.featured-box {
  border-radius: 20px;
    background-color: #000;
    color: #fff;
    padding: 20px;
    margin: 0 auto;
    margin-top: 10px;
    overflow: visible;
    width: auto;    
    max-width: 1160px; 
}

.featured-box h4 {
    font-size: 20px;
    color: #fff;

}

.myimage {

    float:right;
}

.featured-box p {
    padding: 0 0 20px;
}

.featured-box ul {
    margin: 0 0 20px;
}

.featured-box ul li {
    list-style-type: disc;
    margin: 0 0 0 30px;
    padding: 0;
    align: right;
}

.featured-box .enews p {
    padding: 10 10 10 10px;
    color: #fff;
    float: left;
    width: 220 px;
    margin: 10 10 10 10px;

}

.featured-box .enews #subscribe {
    padding: 20 20 20 20px;;

}

.featured-box .enews #subbox {
    background-color: #fff;
    margin: 0;
    width: 300px;

}

.featured-box .enews .myimage {

      float: right;
      margin-left: 10px;
      margin-right: 50px;
       width: auto;
}

section.enews-widget {
   overflow: hidden;
}


.featured-box .enews input[type="submit"] { 
background-color: #d60000;
     padding: 10 10 10 10px;
     width: 150px;

}


@media screen and (min-width: 1140px) {
  div.featured-box {
    margin-top: 10%;
  }
}

@media only screen and (max-width: 767px) {
 section.enews-widget {
 clear: both;
}
.myimage {
  float: none;
}
.myimage img {
  display: block;
  height: auto;
  margin: 0 auto;
 }
}

#text-4 > div:nth-child(1) > h4:nth-child(1) {
        color: #fff;
        font-size: 1.3em; font-weight: normal;
        text-transform: uppercase;
        background-color: #d60000; 
        position: relative;
        margin: 0px -60px 20px -20px;
        padding: 18px 0px 16px 20px;

 }

 #text-4 > div:nth-child(1) > h4:nth-child(1):after {
            content: '';
            display: block; height: 40px; width: 40px;
            background: url(http://bryancollins.eu/wp/wp-content/uploads/2014/04/fold.png) no-repeat 0 0; 
            position: absolute; right: 0px; bottom: -40px;

 }

 .page p { line-height: 1.2em; }
 .page a { color: #1badd2; text-decoration: none; }
 .widget li  { 

            margin: 0;  
            padding: 2px 0px 8px 35px; 
            display: inline; position: relative; 
            border-bottom: none;

}


 .featured-box .widget li {
            list-style: none;
            background: url("http://bryancollins.eu/wp/wp-content/uploads/2014/04/arrow.png") no-repeat scroll 0 10px rgba(0, 0, 0, 0);
            display: inline;
            margin: 0 0 0 30px;
            padding: 0 0 0 40px;
 }

我的HTML:

<div class="featured-box widget-area">

    <section id="text-4" class="widget widget_text">
        <div class="widget-wrap">
            <h4 class="widget-title widgettitle">

                Get this for free

            </h4>
            <div class="textwidget">
                <div class="myimage">
                    <img src="http://bryancollins.eu/wp/wp-content/uploads/2014/04/Book-cover.png"></img>
                </div>
            </div>
        </div>
    </section>
    <section id="enews-ext-3" class="widget enews-widget">
        <div class="widget-wrap">
            <div class="enews">
                <h4 class="widget-title widgettitle">

                    33 Creative Strategies for your next writing proje…

                </h4>
                <p>

                    Lorem ipsum dolor sit amet, consectetur adipiscing…

                </p>
                <div class="arrows">
                    <ul>
                        <li>

                            List item 1

                        </li>
                        <li>

                            List item 2

                        </li>
                        <li>

                            List item 3

                        </li>
                    </ul>
                </div>
                <p>

                    Tuo vero id quidem, inquam, arbitratu. Illud mihi …

                </p>
                <form id="subscribe" name="33 Creative Strategies for your next writing project" onsubmit="if ( subbox1.value == 'First Name') { subbox1.value = ''; } if ( subbox2.value == 'Last Name') { subbox2.value = ''; }" target="_blank" method="post" action="<!-- Begin MailChimp Signup Form --> <div id="mc_embed_signu…s="button"></div> </form> </div> <!--End mc_embed_signup-->"></form>
            </div>
        </div>
    </section>

感谢您的帮助。

2 个答案:

答案 0 :(得分:2)

修复1.)需要增加1024px和1140px之间的上边距可能多于或少于14%但在14时看起来没问题!

@media screen and  (min-width: 1024px) and (max-width: 1140px) {
    div.featured-box {
      margin-top: 14%;
   }
}

用户使用margin-top 130px修复。

修复2。)

尝试添加&溢出:隐藏&#39;到相同的媒体查询:

@media screen and (min-width: 1024px) {
    div.featured-box {
        margin-top: 130px;
        overflow: hidden;
    }
}

答案 1 :(得分:0)

对于您的第一个问题,在“桌面尺寸”上,您的精选框的margin-top 10%,但是一旦您调整到1040px以下,精选框就会采用默认的CSS其中margin-top 10px ,导航具有固定的定位意味着特色框边距顶部是从窗口顶部开始,而不是从导航下方。

要解决此问题,您可以更改默认CSS以使用上边距的百分比,但我建议使用相对定位并使用像素设置边距。另一种选择是增加断点,以便“移动”导航在包装后立即替换默认导航。

对于第二个问题,您可以设置“overflow:hidden;”在包含div或你可以使用视口元标记(移动)将最大比例设置为1,我建议同时做两个:

<meta name="viewport" content="initial-scale=1, maximum-scale=1">
相关问题