2017-09-02 11 views
0

浮動小数点浮動小数点表示をページ全体の左側に作成するには、どうすれば縦方向の中央左に配置できますか?ページの左側中央に浮動小数点浮動小数点

私のhtmlコードは単純です:

<body> 
    <div class="num_book"> 
    <img src="imgs\PhoneDir.png" alt="phone dir" height="142.2" width="45.6"> 
    </div> 
</body> 

私のCSSは、これまでのところです:

.num_book { 
    float: left; 
} 

私はCSSで試してみた:位置、マージン、パディング、ディスプレイ、垂直-合わせいいえ運は、 任意のアイデア?私はflexboxを使用して、このようにそれを行うだろう

答えて

0

.wrapper { 
 
    /* vertical bar on left side */ 
 
    height: 100%; 
 
    left: 0; 
 
    position: fixed; 
 
    top: 0; \t 
 

 
    /* align items inside vertically centered */ 
 
    align-items: center; 
 
    display: flex; 
 
} 
 
.centered { 
 
    background-color: red; 
 
}
<div class="wrapper"> 
 
    <div class="centered">Hello!</div> 
 
</div>

.wrapperが左側に固定(see position)垂直バーです、および.centered内側は中心に垂直に配置されています(display: flexおよびalign-items参照)。

0

body{ 
 
    width: 100vw; 
 
    height: 100vh; 
 
    position: relative; 
 
} 
 

 
.box{ 
 
    width: 200px; 
 
    height: 200px; 
 
    background: red; 
 
    position: fixed; 
 
    bottom: 0px; 
 
    top: 0px; 
 
    left: 0px; 
 
    margin: auto; 
 
}
<body> 
 
    <div class="box"></div> 
 

 
<body>

0

一つの方法は、50%、絶対位置に上面を設定することです。

<style> 
    .num_book { 
     float: left; 
     top:50%; 
     position:absolute; 
    } 
    </style> 
    <body> 
     <div class="num_book"> 
     <img src="imgs\PhoneDir.png" alt="phone dir" height="64" width="64"> 
     </div> 
    </body> 
関連する問題