简体   繁体   English

全宽响应式两列布局图像和文本

[英]Fullwidth responsive two column layout image and text

I'm trying to look for clues to design a banner like the one on the top of this page: https://www.gazteaukera.euskadi.eus/inicio/我正在尝试寻找设计横幅的线索,例如本页顶部的横幅: https://www.gazteaukera.euskadi.eus/inicio/

I am trying myself but don't get what I want (see below).我正在尝试自己,但没有得到我想要的(见下文)。 I want to have an image column on the left and a text column on the right perfectly aligned.我想在左边有一个图像列,在右边有一个文本列完全对齐。 I want it to be responsive, so that in smaller screens the left column will be placed on top of the right column (with no space between top and bottom divs).我希望它具有响应性,以便在较小的屏幕中,左列将放置在右列的顶部(顶部和底部 div 之间没有空间)。

I am having some issues getting what I want.我在得到我想要的东西时遇到了一些问题。 I hope someone can help me:)我希望有一个人可以帮助我:)

code:代码:

 .row { background-color: blue; padding: 0px; /*I have added a background-color to help me solve the design issues, but this is sthg to be removed*/}.column { float: left; width: 50%; padding: 0px; }.row:after { content: ""; display: table; clear: both; }.title { font-size: 24px; color: #0FD955; padding: 15px 15px 0px 15px; font-weight: bold;}.text { font-size: 18px; color: #0FD955; padding: 0px 15px 15px 15px; }.imgw100 { width: 100%; } @media screen and (max-width: 980px) {.column { width: 100%; }.right { width: 100%; }.left { width: 100%; } }
 <div class="row"> <div class="column right"> <img class="imgw100" src="https://butterfly-conservation.org/sites/default/files/styles/masthead/public/2019-03/16548509661_3bdddd5179_o.jpg" /> </div> <div class="column left" style="background-color: #022C11;"> <p class="title">Breaking news</p> <p class="text">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> </div>

Add display css to row as flex for larger devices add for small screen add display css as block for row将显示 css 添加到行作为较大设备的 flex 添加用于小屏幕 添加显示 css 作为行的块

.row {
    background-color: blue;
    padding: 0px;
    display: flex;
}

.title {
    font-size: 24px;
    color: #0fd955;
    padding: 15px 15px 0px 15px;
    font-weight: bold;
}

.text {
    font-size: 18px;
    color: #0fd955;
    padding: 0px 15px 15px 15px;
}

.imgw100 {
    width: 100%;
}

@media screen and (max-width: 480px) {
    .row {
        background-color: blue;
        padding: 0px;
        display: block;
    }
}

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

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