繁体   English   中英

使文字低于图像响应

[英]Get text to go below image responsive

我正在尝试使媒体查询正常工作,但是image显示在屏幕的100%(我想要的)上,但是.right上的文本仍在original声明中float (请参见白色的“文本”在图片的右边)。

这是media queries css

@media screen 
  and (max-width: 480px){ 
    #header .header_adjust{
        width:98%;
    }

    #header .header_adjust .left {

        width:100%;
        height: auto;
        margin:0%;
        background-color:red;
    }
        #header .left img{
            margin:0%;
            width:100%;
            height:auto;

        }

    #header .header_adjust .right {
        float:none;
        width:100%;
        height:auto;
        clear:both;
        margin:0%;
        background-color:black;
    }
  }

原始CSS:

#header .header_adjust {
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
    }

    #header .left{
        width:17.95833335%;
        float:left;
/*      background-color: red;*/
    }
        #header .left img{
            margin:0%;
            max-width:100%;
            max-height:100%;
            -moz-border-radius:5px 20px 5px; -webkit-border-radius:5px 20px 5px; border-radius:5px 20px 5px;
        }
    #header .right{
        width:79.95833335%;
        max-height:100%;
        min-height:100%;
        margin:0% 1%;
        /*background-color: red;*/
        background:
            linear-gradient(27deg, #151515 5px, transparent 5px) 0 5px,
            linear-gradient(207deg, #151515 5px, transparent 5px) 10px 0px,
            linear-gradient(27deg, #222 5px, transparent 5px) 0px 10px,
            linear-gradient(207deg, #222 5px, transparent 5px) 10px 5px,
            linear-gradient(90deg, #1b1b1b 10px, transparent 10px),
            linear-gradient(#1d1d1d 25%, #1a1a1a 25%, #1a1a1a 50%, transparent 50%, transparent 75%, #242424 75%, #242424);
            background-color: #131313;
            background-size: 20px 20px;
        -moz-border-radius:5px;
        -webkit-border-radius:5px;
        border-radius:5px;
        -webkit-flex: 1;
        -ms-flex: 1;
        flex: 1;
        float:right;
    }

的HTML:

<div class="header_adjust">
    <div class="left">
        <img src="{{ url_for('static', filename='my_pic.jpg') }}" alt="My Pic" />
    </div><!--left-->
    <div class="right">
        <h2>
        Test test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Tes              
        </h2>
    </div><!--right-->
    <div id="clear"> </div>
</div><!--header_adjust-->

使用display: flex ,即使未浮动子元素,它们也将并排显示。 看到这里: https : //css-tricks.com/snippets/css/a-guide-to-flexbox/

您可以通过包含以下指令来解决问题:

@media screen and (max-width: 480px) { #header .header_adjust { display: block; } }

示例: http//jsfiddle.net/pbosakov/apfy0nLw/

暂无
暂无

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

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