HTML/CSS Css box messing up margin top -


so have css box:

.navigation-div {     text-align:right;     margin-top:14px;     box-shadow:0px 0px 10px rgba(0,0,0,0.47);     padding: 0;     color:#e3e3e3;     background-color: #333; } 

with image , piece of text inside of it

#mailtext {     margin-top:-10px;     display:inline-block;     font-size:20px;     color:white;     font-style:italic; } #mailpicture {     display:inline-block;     margin-top:16px; } 

this html have it:

<div class="navigation-div">     <nav class="navigation">         <h1 id="mailtext">mail us</h1>         <a href="mailto:info@email.com"><img id="mailpicture" src="images/gmail.png"></a>     </nav> </div> 

currently there no styling class navigation. mail picture in correct position, text want go upwards. can see #mailtext styling have margin-top:-10px; not move text upwards.

how move text upwards or without using margin-top.

this question previous question in way, text not go want (upwards). using margin-left bad, when did move margin top also. since navigation-div has text align of right, might messing up.

how keep text in same position moving margin top without using margin left. keep text on same line image, not above. picture in right place, want move text higher. want text parallel center of image on same line.

the previous question have posted keeping elements on same line, 1 moving margin-top.

to align text little higher need replace margin-top position: relative , top:-10px, in code snippet , fiddle.

for more efficient solution recommend using css property vertical-align. in case if image(size) changed, still align text.

jsfiddle

.navigation-div {    text-align: right;    margin-top: 14px;    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.47);    padding: 0;    color: #e3e3e3;    background-color: #333;  }  #mailtext {    position: relative;    top: -10px;    display: inline-block;    font-size: 20px;    color: white;    font-style: italic;  }  #mailpicture {    display: inline-block;    margin-top: 16px;  }
<div class="navigation-div">    <nav class="navigation">      <h1 id="mailtext">mail us</h1>      <a href="mailto:info@email.com">        <img id="mailpicture" src="images/gmail.png">      </a>    </nav>  </div>


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -