2017-01-11 3 views
0

Ich habe eine Kopfzeile auf meiner Seite und es gibt eine Box mit einem Login-Bild und Ihrem Website-Kontostand. Aber ich versuche, ein Dropdown-Menü mit Optionen hinzuzufügen, aber aus irgendeinem Grund erscheint mein Font Awesome-Symbol unter dem Textfeld. Im Grunde möchte ich nur verstehen, warum mein Font Awesome-Icon unter meinem Textfeld erscheint. Irgendeine Hilfe?Font Awesome Icon erscheint unter Textfeld

JSFiddle: https://jsfiddle.net/nxt4Lzch/

<head> 
    <!--Script Links--> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 

    <script src="js/loading.js"></script> 

    <!--Stylesheet Links--> 
    <link rel="stylesheet" text="text/css" href="css/dropdown.css"> 

    <link rel="stylesheet" text="text/css" href="css/font-awesome.min.css"> 

    <!--Font Links--> 
    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"> 
    <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> 
</head> 

<body> 
    <!--Website Header--> 
    <div id="header"> 
     <div class="steam-box"> 
      <div class="steam-info"> 
       <img class="steam-avatar" src="<?=$steamprofile['avatar'];?>"> 
       <div class="balance-box"> 
        <i class="fa fa-database"> 
         <span class="balance-amount">$201.50</span> 
        </i> 
       </div> 
       <div class="steam-dropdown"> 
        <a href="#"><i class="fa fa-chevron-down"></i></a> 
       </div> 
      </div> 
     </div> 
    </div> 

    <!--Website Sidebar--> 
    <div id="sidebar-menu"> 
     <ul> 
      <li><a href="#"><i class=""></i></a></li> 
      <li><a href="#"><i class="fa fa-area-chart"></i></a></li> 
      <li><a href="#"><i class="fa fa-life-ring"></i></a></li> 
      <li><a href="#"><i class="fa fa-cart-arrow-down"></i></a></li> 
      <li><a href="#"><i class="fa fa-shopping-basket"></i></a></li> 
      <li><a href="#"><i class="fa fa-users"></i></a></li> 
     </ul> 
    </div> 
</body> 

/* Default Stuff */ 
* { 
    margin:0px; 
    padding:0px; 
    text-decoration:none; 
    list-style:none; 
    font-family:"Open Sans", sans-serif; 
} 

/* Website Header */ 
#header { 
    background:rgb(28,28,28); 
    width:100%; 
    height:60px; 
    position:absolute; 
    box-shadow:0px 0px 8px 2px black; 
    border-top:3px solid rgb(235,50,50); 
    z-index:99999999; 
    left:0px; 
    top:0px; 
} 

/* Header (Steam Section) */ 
.steam-box { 
    background:rgb(50,50,50); 
    border-left:3px solid rgb(235,50,50); 
    width:180px; 
    height:40px; 
    position:absolute; 
    z-index:999999999; 
    top:10px; 
    left:1160px; 
} 

.steam-avatar { 
    width:30px; 
    height:30px; 
    margin-left:5px; 
    margin-top:3px; 
    border:2px solid rgb(28,28,28); 
    border-radius:10px; 
} 

.balance-box { 
    height:30px; 
    width:100px; 
    border-radius:10px; 
    position:absolute; 
    margin-top:5px; 
    margin-left:5px; 
    display:inline; 
    background:rgb(28,28,28); 
} 

.balance-box i { 
    color:rgb(255,255,255); 
    line-height:30px; 
    margin-left:10px; 
} 

.balance-amount { 
    color:rgb(255,255,255); 
    font-family:"Montserrat", sans-serif; 
    margin-right:10px; 
} 

.steam-dropdown i { 
    color:rgb(255,255,255); 
    font-size:8px; 
} 

/* Sidebar Menu */ 
#sidebar-menu { 
    background:rgb(41,41,41); 
    width:60px; 
    height:100%; 
    position:absolute; 
    text-align:center; 
    line-height:60px; 
    box-shadow:4px 4px 8px black; 
    left:0px; 
    top:0px; 
} 

#sidebar-menu ul { 
    margin:0px; 
    padding:0px; 
    margin-top:3px; 
} 

#sidebar-menu ul li { 
    list-style:none; 
    height:60px; 
    border-bottom:2px solid rgb(17,17,17); 
} 

#sidebar-menu ul li a { 
    color:rgb(255,255,255); 
    font-size:30px; 
    display:block; 
    height:100% 
    width:100%; 
} 

#sidebar-menu ul li a:hover { 
    background:rgb(255,255,255); 
    color:rgb(41,41,41); 
} 

#sidebar-menu ul li a:active { 
    font-size:25px; 
} 
+0

bitte Ihre Geige noch einmal überprüfen – Raviteja

Antwort

1

Dies liegt daran, Ihre steam-dropdown geschieht, dass die font-awesome icon enthält, ist nicht display:inline;, stattdessen ist es display:block; standardmäßig. Daher benötigt es eine neue Zeile.

Nun, wenn Sie display:inline; diese steam-dropdown hinzufügen, dann wird es in der gleichen Linie bewegen, aber es geht unter .balance-box weil Sie position:absolute; diese .balance-box setzen. Du musst das entfernen.

Ich empfehle das Entfernen position:absolute; von .balance-box und Verwenden Sie Flex auf ihre Eltern Div (die .steam-info ist). Durch Hinzufügen dieses in Ihrem css:

.steam-info{ 
    display:flex; 
    flex-direction:row; 
    align-items:center; 
} 
.steam-dropdown i { 
    margin-left:5px; 
} 

Dies löst das Problem gestellt. Aber könnte ich vorschlagen, left:1160px; durch right:20px; im css für .steam-info zu ersetzen, weil es in kleineren Bildschirmen viel zu recht geht. Ich habe dies in meine Lösung aufgenommen, aber Sie können dies entfernen, wenn Sie das nicht möchten.

Hier ist eine funktionierende fiddle.

Und hier ist ein Arbeits Snippet:

/* Default Stuff */ 
 
* { 
 
\t margin:0px; 
 
\t padding:0px; 
 
\t text-decoration:none; 
 
\t list-style:none; 
 
\t font-family:"Open Sans", sans-serif; 
 
} 
 

 
/* Loading Animation */ 
 
#loading-overlay { 
 
\t height:100%; 
 
\t width:100%; 
 
\t background:rgb(17,17,17); 
 
\t position:fixed; 
 
\t z-index:9999999999; 
 
\t left:0px; 
 
\t top:0px; 
 
} 
 

 
.loading-spinner { 
 
\t width:100px; 
 
\t height:100px; 
 
\t border:2px solid rgb(255,255,255); 
 
\t border-top:3px solid rgb(250,32,32); 
 
\t border-radius:100%; 
 
\t position:absolute; 
 
\t top:0px; 
 
\t bottom:0px; 
 
\t left:0px; 
 
\t right:0px; 
 
\t margin:auto; 
 
\t animation:loading-spin 1s infinite linear; 
 
} 
 

 
@keyframes loading-spin { 
 
\t from { 
 
\t \t transform:rotate(0deg); 
 
\t } to { 
 
\t \t transform:rotate(360deg); 
 
\t } 
 
} 
 

 
/* Website Header */ 
 
#header { 
 
\t background:rgb(28,28,28); 
 
\t width:100%; 
 
\t height:60px; 
 
\t position:absolute; 
 
\t box-shadow:0px 0px 8px 2px black; 
 
\t border-top:3px solid rgb(235,50,50); 
 
\t z-index:99999999; 
 
\t left:0px; 
 
\t top:0px; 
 
} 
 

 
/* Header (Steam Section) */ 
 
.steam-box { 
 
\t background:rgb(50,50,50); 
 
\t border-left:3px solid rgb(235,50,50);; 
 
\t width:180px; 
 
\t height:40px; 
 
\t position:absolute; 
 
\t z-index:999999999; 
 
\t top:10px; 
 
\t right:20px; 
 
} 
 

 
.steam-avatar { 
 
\t width:30px; 
 
\t height:30px; 
 
\t margin-left:5px; 
 
\t margin-top:3px; 
 
\t border:2px solid rgb(28,28,28); 
 
\t border-radius:10px; 
 
} 
 

 
.balance-box { 
 
\t height:30px; 
 
\t width:100px; 
 
\t border-radius:10px; 
 
\t //position:absolute; 
 
\t margin-top:5px; 
 
\t margin-left:5px; 
 
\t display:inline; 
 
\t background:rgb(28,28,28); 
 
} 
 

 
.balance-box i { 
 
\t color:rgb(255,255,255); 
 
\t line-height:30px; 
 
\t margin-left:10px; 
 
} 
 

 
.balance-amount { 
 
\t color:rgb(255,255,255); 
 
\t font-family:"Montserrat", sans-serif; 
 
\t margin-right:10px; 
 
} 
 

 
.steam-dropdown i { 
 
\t color:rgb(255,255,255); 
 
\t font-size:8px; 
 
} 
 

 
/* Sidebar Menu */ 
 
#sidebar-menu { 
 
\t background:rgb(41,41,41); 
 
\t width:60px; 
 
\t height:100%; 
 
\t position:absolute; 
 
\t text-align:center; 
 
\t line-height:60px; 
 
\t box-shadow:4px 4px 8px black; 
 
\t left:0px; 
 
\t top:0px; 
 
} 
 

 
#sidebar-menu ul { 
 
\t margin:0px; 
 
\t padding:0px; 
 
\t margin-top:3px; 
 
} 
 

 
#sidebar-menu ul li { 
 
\t list-style:none; 
 
\t height:60px; 
 
\t border-bottom:2px solid rgb(17,17,17); 
 
} 
 

 
#sidebar-menu ul li a { 
 
\t color:rgb(255,255,255); 
 
\t font-size:30px; 
 
\t display:block; 
 
\t height:100% 
 
\t width:100%; 
 
} 
 

 
#sidebar-menu ul li a:hover { 
 
\t background:rgb(255,255,255); 
 
\t color:rgb(41,41,41); 
 
} 
 

 
#sidebar-menu ul li a:active { 
 
\t font-size:25px; 
 
} 
 

 
.steam-info{ 
 
    display:flex; 
 
    flex-direction:row; 
 
    align-items:center; 
 
} 
 
.steam-dropdown{ 
 
    flex-grow:1; 
 
} 
 
.steam-dropdown a{ 
 
    display:block; 
 
    width:100%; 
 
    margin:0; 
 
    padding:0; 
 
    height:100%; 
 
    text-align:center; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
\t \t <!--Loading Animation 
 
\t \t <div id="loading-overlay"> 
 
\t \t \t <div class="loading-spinner"></div> 
 
\t \t </div>--> 
 

 
\t \t <!--Website Header--> 
 
\t \t <div id="header"> 
 
\t \t \t <div class="steam-box"> 
 
\t \t <? if(isset($_SESSION['steamid'])) {?> 
 
\t \t \t \t <div class="steam-info"> 
 
\t \t \t \t \t <img class="steam-avatar" src="http://www.chinabuddhismencyclopedia.com/en/images/thumb/b/b8/Nature.jpg/240px-Nature.jpg"> 
 
\t \t \t \t \t <div class="balance-box"> 
 
\t \t \t \t \t \t <i class="fa fa-database"> 
 
\t \t \t \t \t \t \t <span class="balance-amount">$201.50</span> 
 
\t \t \t \t \t \t </i> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t <div class="steam-dropdown"> 
 
\t \t \t \t \t \t <a href="#"><i class="fa fa-chevron-down"></i></a> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t <? } else {?> 
 
\t \t \t 
 
\t \t <? } ?> 
 
\t \t \t </div> 
 
\t \t </div> 
 

 
\t \t <!--Website Sidebar--> 
 
\t \t <div id="sidebar-menu"> 
 
\t \t \t <ul> 
 
\t \t \t \t <li><a href="#"><i class=""></i></a></li> 
 
\t \t \t \t <li><a href="#"><i class="fa fa-area-chart"></i></a></li> 
 
\t \t \t \t <li><a href="#"><i class="fa fa-life-ring"></i></a></li> 
 
\t \t \t \t <li><a href="#"><i class="fa fa-cart-arrow-down"></i></a></li> 
 
\t \t \t \t <li><a href="#"><i class="fa fa-shopping-basket"></i></a></li> 
 
\t \t \t \t <li><a href="#"><i class="fa fa-users"></i></a></li> 
 
\t \t \t </ul> 
 
\t \t </div>

+0

Ok nur noch eine Frage. Wie finde ich das Zentrum perfekt, so dass ich mein Symbol zwischen der linken und der rechten Box ausrichten kann? – Abyssal

+0

ok. Ich verstehe deine Frage. aber ich habe jetzt keinen Überschuss zu meinem PC. Kannst du bitte warten bis ich hime bin. – ab29007

+0

OK. Ich habe meine Antwort aktualisiert, Sie können es jetzt überprüfen. – ab29007

Verwandte Themen