简体   繁体   中英

Div appears to remove from the center when viewed on larger screen

I have a section of my home page that when viewed in screen sizes other than the one I am working on, it changes position. I think it is to do with the position element but I am not sure exactly what it should be set to or where it should be placed within my CSS.

The section I want remaining in the same place is a jquery image transition which is shown below the navigation menu within the image. See HTML and CSS below aswel for further reference.

Thank you for any help guys

在此处输入图片说明

HTML:

<body>
<div id="top_bar">
<div id="top_inner">
<div id="logo"> <a href="http://www.edosbornephotography.com"><img src="images/logo.gif" alt="Ed Osborne" width="225" height="115" class="logo"></a></div>
<div class="nav">
<ul class = "menu" >
            <li> <a href = "#" > Home </a> </li>
            <li><a href = "#" > Packages </a>
            <li><a href = "#" > Weddings </a>
            <li><a href = "#" id="left" > Lifestyle </a>
        <ul class = "submenu" >
            <li> <a href = "#" > Families </a> </li>
            <li> <a href = "#"> Newborn/Child </a> </li>
            <li> <a href = "#" > Portraits </a> </li>
        </ul>
        </li>

        <li> <a href = "#" > Blog </a> </li>
        <li><a href = "#" id="left"> Abous Us </a>
        <ul class = "submenu" >
        <li> <a href = "#" > Ed Osborne </a> </li>
        <li> <a href = "#" > Testimonials </a> </li>
        <li> <a href = "#" > FAQs </a> </li>
        </ul>
        </li>

        <li> <a href = "#" > Contact Us </a> </li>
        <li> <a href = "#" > Links </a> </li>
        </ul>
    </div>
</div>
</div>

<div id="main">  

<div id="smart-gallery">
    <a href="images/cubagallery-img-1.jpg">
        <img src="images/cubagallery-img-1.jpg" /></a> 

    <a href="images/cubagallery-img-15.jpg">
        <img src="images/cubagallery-img-15.jpg" /></a> 

    <a href="images/cubagallery-img-3.jpg">
        <img src="images/cubagallery-img-3.jpg" /></a> 

    <a href="images/cubagallery-img-4.jpg"></a>
        <img src="images/cubagallery-img-4.jpg" /></a>
</div>

</div>

CSS:

#top_bar {
width: 100%;
height: 145px;
background: #000000;
padding-bottom: 20px;
}

#top_inner {
text-align: center;
margin: 0 auto;
width: 1000px;
height: 144px;
}

.nav {
margin: 0 auto;
position: relative;
padding-top: 100px;
}

ul.menu {
list-style: none;
margin: 0;
float: left;
background: #222;
font-size: 1.2em;
background: url(../images/topnav_bg.gif) repeat-x;
}

ul.menu li {
float: left;
margin: 0;  
position: relative; 
}

ul.menu li span { 
width: 11px;
height: 35px;
float: left;
background: url(../images/subnav_btn.gif) no-repeat center top;
}

.min-gallery
{
width: 927px;
height: 615px;
border: solid 1px black;
background-color: Black;
background: url(../images/bg.jpg);
margin: auto;
margin-left: 232px;
}

.min-gallery .preview
{
width: 852px;
height: 493px;
margin-top: 36px;
margin-left: 36px;
margin-right: 36px;
position: relative;
border: solid 2px black;
overflow: hidden;
background-color: White;
}

.min-gallery .preview img
{
width: 795px;             
height: 525px;
position: absolute;
}

.min-gallery .bottom
{
width: 100%;
height: 98px;
color: Gray;
font-family: Arial;
font-size: 1em;
font-weight: bold;
overflow: hidden;
}

You html code does not contain any element with min-gallery class... but if you change it min-gallery with smart-gallery:

.smart-gallery
{
    width: 927px;
    height: 615px;
    border: solid 1px black;
    background-color: Black;
    background: url(../images/bg.jpg);
    margin: auto;
    margin-left: 232px; <- remove
}
.smart-gallery...

You can use percentages rather than pixels to position the gallery. A better way would be to use css media queries, so as the window changes so does the size and placement of your div.

There is not enough info here for me to write any pseudo code, and I couldn't load your site. But the following sites should get you started in the right direction.

Quick tips a crash course in media queries

Adaptive layouts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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