首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >响应式WordPress功能框导致两个问题

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

Stack Overflow用户
提问于 2014-04-22 03:42:03
回答 2查看 353关注 0票数 0

我在我的WordPress development site上创建了一个功能框。在一些帮助下,我使功能框具有响应性,它几乎完成了。您可以在下面的屏幕截图中看到此功能框正确显示

然而,我有两个问题:

1)当我缩小浏览器窗口时,导航栏会扩展到两行,并覆盖我的功能框(如图所示)。我希望功能框随着导航栏的扩展而下移。

2)在我的手机上,我的功能框中的红色彩带超出了页面的宽度,导致导航栏显示错误(如图所示)。我不想让红丝带扩展到超出导航栏的宽度。

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

我的相关CSS是

代码语言:javascript
复制
.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:

代码语言:javascript
复制
<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>

谢谢你的帮助。

EN

回答 2

Stack Overflow用户

发布于 2014-04-22 04:58:12

修复%1。)需要增加1024px和1140px之间的上边距可以超过或低于14%,但看起来可以在14!

代码语言:javascript
复制
@media screen and  (min-width: 1024px) and (max-width: 1140px) {
    div.featured-box {
      margin-top: 14%;
   }
}

用户已修复页边距-顶部130px。

修复2。)

请尝试向同一媒体查询中添加“overflow:hidden”:

代码语言:javascript
复制
@media screen and (min-width: 1024px) {
    div.featured-box {
        margin-top: 130px;
        overflow: hidden;
    }
}
票数 2
EN

Stack Overflow用户

发布于 2014-04-22 04:53:40

对于你的第一个问题,在“桌面大小”上,你的特色框有一个10%margin-top,但是一旦你调整到1040px以下,特色框就会采用默认的CSS,它的margin-top10px,导航有固定的位置,这意味着特色框的页边距顶部是从窗口的顶部,而不是从下面的导航。

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

对于第二个问题,您可以在包含的div上设置"overflow:hidden;“,也可以使用viewport元标记(Mobile)将最大比例设置为1,我建议您同时执行这两种操作:

代码语言:javascript
复制
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23204673

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档