Banner Image Placement and Proportion

322 views Asked by At

I am working on a project and for some reason I cannot get the banner placed in the position I want. There is code I am looking at hat has it set how I want to be:

HTML:

            <!doctype html>
            <html lang="en">
            <head>
                <meta charset="utf-8">
                <title>Title</title>
                <link rel="stylesheet" href="css/styles.css">
            </head>
            <body>
            <div class="container">

                <header>
                    <h1>
                        <a href="index.html">
                            <img src="images/logo.png" alt="logo">
                            <!--<div>-->
                                They're Animals
                            <!--</div>-->
                        </a>
                    </h1>
                </header>



            </div><!--.container-->
            </body>
            </html>

and the CSS that works for my ideal banner is:

            /*  *************************************
                Base
                ************************************* */
            body { 
                background-color: #dfeff0;
                color: #333333;
                font-family: Arial, Helvetica, sans-serif;
            }

            header a { color: #ad235e;}
            header a:hover { color: #000000;}
            h1 {
                color: #ad235e;
                font-size: 14px;
            }
            h1 a:hover img { opacity: 0.7;}


            /*  *************************************
                Modules
                ************************************* */
            .container {
                margin: 0 auto;
                width: 90%;
                max-width: 960px;
                position: relative;
            }

I have tried copying the CSS to put in my project (and the html) and it still does not work.

With actual text and more information in there it flows perfectly.

I guess something that might be more helpful is the code I have tried on my own:

            <!doctype html>

                <html lang="en">

                <head>
                    <meta charset="utf-8">
                    <title>Title</title>
                    <link rel="stylesheet" href="css/styles.css">
                </head>

                <div class="container">

                <header>
                    <h1>
                      <img src="images/banner.png" alt="banner">
                        <!--<body background="images/banner.png" alt="banner" >-->
                        Home Page
                    </h1>

                </header>

                </div>

and my attempt at CSS:

            h1
                {
                text-decoration:underline;
                text-align:center;

                }

            h1 img
                {
                height: 40%;
                width: 40%;
                margin: 0px 10px;
                padding: 5px;
                float: left;
                }
            .container
                {
                width: 80%;
                max-width: 960px;
                margin:0px auto;
                }

I guess the simplest way to put this is I am trying to get my banner to be an appropriate size (though I can manage that by editing the width and height) to the left of my h1 without pushing everything making it seem that it is "alone".

This is what I would like my header to look like (the logo right next to the title without it pushing the content away

With my content on my page, this is how it actually looks.

1

There are 1 answers

1
Raihan Taher On

I am not sure exactly what you want to do. But I am guessing as you are using float:left you are maybe facing problem with the class "container".

I believe you can add one line in your .container CSS and fix the problem.

overflow: auto;