2017-05-15 16 views
1

画像の右側にナビゲーションメニューを配置しようとしていますが、その位置にテキストを配置することができましたが、リストを中央に配置する方法がわかりません私がjustify content: center;を使用していた場合、私のようなものです。彼らは一直線になり、左にマッチします。フレックスボックス列を使用してリストアイテムを整列する

.landing { 
 
    background-image: url(http://adwallpapers.xyz/uploads/posts/72363-blonde-girl-blur-photo-4k-ultra-hd-wallpaper__celebrity.jpg); 
 
    margin-left: 40px; 
 
    margin-right: 40px; 
 
    height: calc(100vh - 0px); 
 
    background-size: cover; 
 
    background-position: center center; 
 
} 
 

 
ul { 
 
    display: flex; 
 
    flex-direction: column; 
 
    padding: 0; 
 
    align-items: flex-end; 
 
} 
 

 
li { 
 
    list-style: none; 
 
    color: white; 
 
    font-size: 25px; 
 
    position: relative; 
 
    top: 400px; 
 
    right: 50px; 
 
}
<div class="landing"> 
 
    <ul> 
 
    <li>One</li> 
 
    <li>Two</li> 
 
    <li>Three</li> 
 
    </ul> 
 
</div>

https://jsfiddle.net/oanja0xL/

+1

正確に何を達成しようとしていますか?弾丸のポイントは、画像の中央まで並んでいるはずですか? –

+0

このケースでは、おそらくFlexboxが最適なソリューションではありません。これを試してください:https://jsfiddle.net/oanja0xL/1/ –

答えて

1

私はあなたがフレキシボックスなしのほうが良いと思います。私はあなたのCSSを変更し、変更が行われたことを示しました。

.landing { 
 
    background-image: url(http://adwallpapers.xyz/uploads/posts/72363-blonde-girl-blur-photo-4k-ultra-hd-wallpaper__celebrity.jpg); 
 
    margin-left: 40px; 
 
    margin-right: 40px; 
 
    height: calc(100vh - 0px); 
 
    background-size: cover; 
 
    background-position: center center; 
 

 
    /* new */ 
 
    text-align: right; 
 
} 
 

 
ul { 
 
    /*display: flex;*/ 
 
    /*flex-direction: column;*/ 
 
    padding: 0; 
 
    /*align-items: flex-end;*/ 
 

 
    /* new */ 
 
    text-align: center; 
 
    display: inline-block; 
 
    margin-right: 10px; 
 
    margin-top: 30px; 
 
} 
 

 

 
li { 
 
    list-style: none; 
 
    color: white; 
 
    font-size: 25px; 
 
    /*position: relative;*/ 
 
    /*top: 400px;*/ 
 
    /*right: 50px;*/ 
 
}
<div class="landing"> 
 
    <ul> 
 
\t <li>One</li> 
 
\t <li>Two</li> 
 
\t <li>Three</li> 
 
    </ul> 
 
</div>

0

あなたも、背景画像フレックス要素の入った容器を作ることができます。それを子要素の移動に使用できます。以下のサンプルを参照してください。

.landing { 
 
\t  background-image: url(http://adwallpapers.xyz/uploads/posts/72363-blonde-girl-blur-photo-4k-ultra-hd-wallpaper__celebrity.jpg); 
 
    margin-left: 40px; 
 
    margin-right: 40px; 
 
    height: calc(100vh - 0px); 
 
    background-size: cover; 
 
    background-position: center center; 
 
    display: flex;/**Added this**/ 
 
    align-items: center; /**Added this**/ 
 
    justify-content: flex-end; /**Added this**/ 
 
} 
 

 
ul { 
 
    display: flex; 
 
    flex-direction: column; 
 
    padding: 0; 
 
\t /**align-items: flex-end; Removed this **/ 
 
} 
 

 

 
li { 
 
    list-style: none; 
 
    color: white; 
 
    font-size: 25px; 
 
    position: relative; 
 
    /* top: 400px; Removed this*/ 
 
    right: 50px; 
 
}
<div class="landing"> 
 
    <ul> 
 
\t <li>One</li> 
 
\t <li>Two</li> 
 
\t <li>Three</li> 
 
    </ul> 
 
</div>

関連する問題