简体   繁体   English

将两个DIV与图像并排对齐并做出响应

[英]Aligning two DIVs with images side by side and making responsive

I'm really hoping someone can help me here as I've been working on this for days now and don't have any hair left to pull out!!!! 我真的希望有人可以在这里为我提供帮助,因为我已经为此工作了好几天,并且没有多余的头发可以拉!

I'm working on a Wordpress site and trying to get the logo and an image to line up side by side and be somewhat responsive. 我正在一个Wordpress网站上工作,试图使徽标和图像并排排列并有所响应。 I've got it working perfectly in Firefox and Chrome using 'display: inline-flex' but know that wont work for Safari width 700px - 960px or iPad portrait view where in both cases the logo and image stack on top of one another. 我已经使用'display:inline-flex'在Firefox和Chrome中完美运行,但是知道对于Safari宽度700px-960px或iPad纵向视图而言,它们在徽标和图像相互叠放的情况下无法正常工作。

They should remain side by side until the screen width gets down to 700px then I'm happy for them to stack. 它们应该并排放置,直到屏幕宽度减小到700px,然后我很高兴可以堆叠它们。

If anyone could help me out with the code required to get this working cross browsers I'd REALLY appreciate it. 如果有人能帮助我解决跨平台浏览器所需的代码,我将非常感谢。

Here is the site 这是网站

I don't think it complicates matters but the code for the logo is PHP rather than straight HTML, the code for the advert at the bottom is HTML (added by me) 我认为这不会使事情复杂化,但是徽标的代码是PHP而不是纯HTML,底部广告的代码是HTML(由我添加)

        <?php
        $use_header_banner = et_get_option( 'lucid_468_header_enable', 'false' );
    ?>

    <div id="pt-header" class="container">
        <div id="logo-area"<?php if ( 'on' == $use_header_banner ) echo ' class="header_banner clearfix"'; ?>>
            <a href="<?php echo esc_url( home_url( '/' ) ); ?>">
            <?php
                    $color_scheme = et_get_option( 'lucid_color_scheme', 'Orange' );
                    $color_scheme = ( 'Orange' == $color_scheme ) ? '' : '-' . strtolower( $color_scheme );
                    $logo = ( ( $user_logo = et_get_option('lucid_logo') ) && '' != $user_logo ) ? $user_logo : get_template_directory_uri() . "/images/logo{$color_scheme}.png";
                ?>
                <img src="<?php echo esc_url ( $logo ); ?>" alt="<?php echo esc_attr( get_bloginfo('name')) ; ?>" id="logo"/>
            </a>
            <?php if ( 'on' == $use_header_banner ){ ?>
                <div id="top_banner">
                    <?php
                    if ( ( $lucid_468_header_adsense = et_get_option('lucid_468_header_adsense') ) && '' != $lucid_468_header_adsense ) echo( $lucid_468_header_adsense );
                        else { ?>
                           <a href="<?php echo esc_url(et_get_option('lucid_468_header_url')); ?>"><img src="<?php echo esc_attr(et_get_option('lucid_468_header_image')); ?>" /></a>
                    <?php } ?>
                </div> <!-- end #top_banner -->
            <?php } ?>
        </div>
<div id="head-ad">
    <a href="http://www.focus-training.com/"><img src="http://sievecreative.co.uk/development/testsite/wp-content/uploads/ads/header.png" /></a>
</div>
    </div> <!-- end .container -->

Which ends up looking like this 最终看起来像这样

<div id="pt-header" class="container">
<div id="logo-area">
<a href="http://sievecreative.co.uk/development/testsite/">
<img id="logo" alt="PT Magazine" src="http://sievecreative.co.uk/development/testsite/wp-content/uploads/2013/09/logo.jpeg">
</a>
</div>
<div id="head-ad">
<a href="http://www.focus-training.com/">
<img src="http://sievecreative.co.uk/development/testsite/wp-content/uploads/ads/header.png">
</a>
</div>
</div>

Here is all the associated CSS 这是所有关联的CSS

#pt-header {
    margin-bottom: -2px;
    }

#logo-area img {
    float: left;
    padding-bottom: 11px;
    padding-top: 20px;
    clear: both;
}

.container #logo-area {
    margin-bottom: 0px;
    text-align: center;
}

#head-ad img {
    padding-left: 40px;
}

img {
    height: auto;
    max-width: 100%;
    width: auto;
}

@media only screen and ( min-width: 700px ) and ( max-width: 960px ) {
#pt-header {display: inline-flex;}
}

Thanks for looking. 感谢您的光临。

感谢所有看过的人,我现在使用响应式网格系统链接对它进行了排序

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

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