CSS样式 - 导航到不同页面时,元素会略微移动

时间:2015-03-18 18:19:23

标签: html css navigation web webpage

由于某些原因,当我导航到我网站上的不同页面时,某些元素似乎会根据您转到的页面轻微移动。这是移动的元素的短clip。正如您所看到的,我的网站元素似乎有些微不足道,我无法解决原因。如果有人能帮助我做到这一点,那么当导航到不同的页面时,一切都保持不变,我将不胜感激。

以下是我的CSS样式:

/*CSS FOR ALL PAGES*/

/*BODY/WRAPPER SECTION*/

body {background:url('E:/Server/CRAFT412-Website/images/SiteBackground.png');
      background-repeat: no-repeat;
      background-attachment: fixed;}

#wrapper {width: 1000px;
          margin: 0 auto;
          background-color: white;
          border-radius: 5px;
          box-shadow: 0px 1px 5px;}

/*TOP BANNER SECTION*/

#logo {margin-top: -90px;
       margin-bottom: -95px;
       text-align: center;}

#ip {float: left;
     margin-left: 458px;
     margin-top: -55px;}

#ip_text {float: left;
          margin-left: 449px;
          margin-top: -51px;
          color: white;
          font-size: 15px;}

#teamspeak_logo {float:right;
                 margin-right: 450px;
                 margin-top: -55px;}

/*TOP NAV BAR SECTION*/

* {margin: 0px;
   padding: 0px;}

#nav_bar {background-color: #a22b2f;
          box-shadow: 0px 1px 10px;
          height: 45px;
          text-align: center;
          border-top-left-radius: 5px;
          border-top-right-radius: 5px;}

#nav_bar ul {padding: 0;}

#nav_bar > ul > li {display: inline-block;}

#nav_bar ul > li > a {color: white;
                      display: block;
                      text-decoration: none;
                      font-weight: normal;
                      padding-left: 15px;
                      padding-right: 15px;
                      line-height: 45px;
                      transition: all 0.5s ease;}

#nav_bar ul li ul {display: none;
                   list-style: none;
                   position: absolute;
                   background: white;
                   margin-left:0px;
                   box-shadow: 0px 1px 5px;
                   text-align: left;
                   z-index:1;}

#nav_bar ul li a.active-page {background-color: #8c1d20;}

#nav_bar ul li:hover ul li a {line-height: 2em;}

#nav_bar ul li a:hover {background: #8c1d20;}

#nav_bar ul li:hover ul {display: block;}

#nav_bar ul li ul li a {color: #252525;
                        display: block;}

#nav_bar ul li ul li a:hover {background: #4485f5;
                              color: white;}

/*BOTTOM FOOTER SECTION*/

#bottom_footer {height: 50px;
                margin: 0px auto;
                margin-top: 15px;
                margin-bottom: 15px;
                background:white;
                width: 1000px;
                border-radius: 5px;
                box-shadow: 0px 1px 5px;}

#created_by {padding: 17px;
             text-align: center;}

#social_media_youtube {float: left;
                       margin: -46px;
                       margin-left: 315px;}

#social_media_twitch {float: left;
                      margin: -43px;
                      margin-left: 380px;}

#social_media_twitter {float: right;
                       margin: -53px;
                       margin-right: 368px;}

#social_media_facebook {float: right;
                        margin: -47px;
                        margin-right: 325px;}

/*ELEMENT SELECTIONS SECTION*/

p {font-family: Arial, Helvetica, sans-serif;
   margin-left: 20px;
   margin-right: 20px;}

ul {font-family: Arial, Helvetica, sans-serif;
    margin-left: 37px;}

h3 {font-family: Arial, Helvetica, sans-serif;
    margin-left: 20px;}

h4 {font-family: Arial, Helvetica, sans-serif;
    margin-left: 20px;}

以下是索引页面中的HTML:

<!DOCTYPE HTML>

<html>

<head>
    <title>CRAFT412 - Home</title>
</head>

<!--PAGE LINKS-->

<link href="css/styles.css" rel="stylesheet" type="text/css" media="screen">
<link href="css/index.css" rel="stylesheet" type="text/css" media="screen">

<!--HTML FOR ALL PAGES-->

<!--BODY SECTION-->

<body>

    <!--TOP BANNER SECTION-->

    <div id="banner">

                   <div id="logo"> 
                                <img src="images/CRAFT412 - Logo.png" width="500" height="281" alt="CRAFT412">
                            </div>

                   <div id="ip">
                              <img class="top" src="images/CRAFT412 - Box - IP.png" alt="IP">
                           </div>

                   <div id="ip_text">
                                   <p>SERVER IP<P/>
                                   <p>craft412.serveminecraft.net<P/>
                               </div>

                   <div id="teamspeak_logo"> 
                                          <a href="ts3server://craft412.serveminecraft.net:9987">
                                          <img src="images/CRAFT412 - Box - Teamspeak.png" alt="TEAMSPEAK"></a>
                                      </div>                                       
                                  </div>

    <!--WRAPPER SECTION-->

    <div id="wrapper">

                    <!--TOP NAV BAR SECTION-->

                    <div id="nav_bar">
                                    <ul>
                                      <li><a href="index.html" class="active-page">Home</a>
                                      </li
                                      ><li><a href="status.html">Status</a>
                                      </li
                                      ><li><a href="info.html">Info</a>
                                      </li
                                      ><li><a href="">Gamemodes</a> 
                                    <ul>
                                       <li><a href="survival.html">Survival</a>
                                       </li
                                       ><li><a href="pure-pvp.html">Pure-PVP</a>
                                       </li
                                       ><li><a href="gamesworld.html">Gamesworld</a>
                                       </li>
                                    </ul>
                                       </li
                                       ><li><a href="rules.html">Rules</a>
                                       </li
                                       ><li><a href="vote.html">Vote</a>
                                       </li
                                       ><li><a href="contact.html">Contact</a>
                                       </li>
                                    </ul>
                                </div>

                    <!--INDEX CONTENT-->

                    <div id="index_banner">
                                         <img class="bottom" src="images/SPAWN IMAGE.png" alt="INDEX BANNER">
                                         <img class="top" src="images/SURVIVAL IMAGE - GAMEMODES.png" alt="INDEX BANNER 2">
                                     </div>

                    <div id="welcome_text">                                        
                                         <h3>Welcome to CRAFT412</h3>
                                         <h3>We are currently running version 1.8.1</h3>
                                         <h3>Survival / PurePVP / GamesWorld</h3>                                       
                                     </div>

                    <div id="trailer_title">                                   
                                          <h4><br>SERVER TRAILER</h4>
                                      </div>

                    <div id="trailer_video">
                                          <iframe width="832" height="468" src="http://www.youtube.com/embed/dfbWw757Iow"></iframe>
                                      </div>
                                  </div>                                                                                                                            

                    <!--HTML FOR ALL PAGES-->

                    <!--BOTTOM FOOTER SECTION-->

                    <div id="bottom_footer">                    
                                          <div id="created_by">
                                                             <p>© 2015 GR412</p>
                                                         </div>

                                          <div id="social_media_youtube"> 
                                                                       <a href="https://www.youtube.com/user/GR412" target="_blank">
                                                                       <img src="images/CRAFT412 - YouTube Button.png" width="40" height="40" alt="YOUTUBE"></a>
                                                                   </div>

                                          <div id="social_media_twitch"> 
                                                                      <a href="http://www.twitch.tv/gr412" target="_blank">
                                                                      <img src="images/CRAFT412 - Twitch Button.png" width="35" height="35" alt="TWITCH"></a>
                                                                  </div>

                                          <div id="social_media_twitter"> 
                                                                       <a href="https://twitter.com/GR412" target="_blank">
                                                                       <img src="images/CRAFT412 - Twitter Button.png" width="55" height="55" alt="TWITTER"></a>
                                                                   </div>

                                          <div id="social_media_facebook"> 
                                                                        <a href="https://www.facebook.com/GR412" target="_blank">
                                                                        <img src="images/CRAFT412 - Facebook Button.png" width="45" height="40" alt="FACEBOOOK"></a>
                                                                   </div>                                                                

    </div>

</body>

</html>

1 个答案:

答案 0 :(得分:-1)

最有可能使用一个或多个&#34;&amp; &#34; s分离您的图像?这些&#34;东西&#34;代表(非破坏性)空间,但是!空间(长度)并不相同:它取决于您使用的FONT。 例如/通常在php中使用include来合并网页的单独部分。我们假设您的图片位于header.php部分。然后,根据请求,添加另一个PHP部分。当该部分使用(通过应用css)新的/其他字体而不是&#39;通常&#39;,这会影响&#34;&amp; &#34;&#39;在整个页面上。寻找像

这样的东西
font-family: "Ubuntu", "Trebuchet MS", sans-serif;

在您的某些页面上(不)出现。