2016-06-20 6 views
-1

私はHTMLを使い慣れていませんし、言語を学んでいますが、このウェブサイトを作成しようとすると、一番上の写真は中央に配置されません。私は縦の整列とパディングを試みましたが、運はゼロです。私のコードを下に置いておきます。CSSでセンターに写真を整列させるのに苦労している

.hudson { 
 
    color: white; 
 
    position: relative; 
 
    font-size: 60px; 
 
    top: 105px; 
 
    font-family: Futura, 'Trebuchet MS', Arial, sans-serif; 
 
    text-align: center; 
 
} 
 
.threeD { 
 
    text-shadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0, 0, 0, .1), 0 0 5px rgba(0, 0, 0, .1), 0 1px 3px rgba(0, 0, 0, .3), 0 3px 5px rgba(0, 0, 0, .2), 0 5px 10px rgba(0, 0, 0, .25), 0 10px 10px rgba(0, 0, 0, .2), 0 20px 20px rgba(0, 0, 0, .15); 
 
} 
 
.p1 { 
 
    position: relative; 
 
    text-align: center; 
 
    top: 70px; 
 
    text-align: center; 
 
    -webkit-animation-delay: 1s; 
 
} 
 
.p2 { 
 
    position: relative; 
 
    text-align: center; 
 
    top: 80px; 
 
    text-align: center; 
 
    -webkit-animation-delay: 1s; 
 
} 
 
.p3 { 
 
    position: relative; 
 
    text-align: center; 
 
    top: 90px; 
 
    text-align: center; 
 
    -webkit-animation-delay: 1s; 
 
} 
 
.coding { 
 
    align-items: center; 
 
    padding: 10px; 
 
} 
 
.paracolor { 
 
    color: skyblue; 
 
    font-size: 25px; 
 
    font-family: Orbitron; 
 
    text-align: center; 
 
} 
 
#icons { 
 
    padding-top: 100px; 
 
    text-align: center; 
 
} 
 
#icons i { 
 
    color: white; 
 
} 
 
body { 
 
    background-image: url(PICTURES1/mountains4.jpeg); 
 
    background-repeat: no-repeat; 
 
}
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Orbitron" /> 
 
<link rel="stylesheet" type="text/css" href="fontawesome/css/font-awesome.min.css"> 
 
<img class="coding animated fadeInDown" src="PICTURES1/coding.png" style="max-width:125px;max-height:125px;"> 
 
<h2 class="hudson threeD animated fadeInDown">Hudson Reamer</h2> 
 
<p class="paracolor p1 animated fadeInRightBig">blah blah blah</p> 
 
<p class="paracolor p2 animated fadeInLeftBig">blah blah blah</p> 
 
<p class="paracolor p3 animated fadeInRightBig">blah blah blah</p> 
 
<div id="icons"> 
 
    <a href="https://www.instagram.com/hreamer/"><i class="fa fa-instagram fa-4x"></i></a> 
 
    <a href="mailto:[email protected]"><i class="fa fa-envelope-o fa-4x"></i></a> 
 
    <a href="https://twitter.com/search?q=%40hreamer&src=typd&lang=en"><i class="fa fa-twitter fa-4x"></i></a> 
 
</div>

+0

Flexboxアイテムに 'align-items'が使用されています。 https://developer.mozilla.org/en-US/docs/Web/CSS/align-items – feeela

+0

私はそれを試みたが、うまくいかなかった。しかし、コメントありがとう!それを質問に入れてくれて申し訳ありません。 – CookieM

答えて

3

あなたは、左右の余白値autoを使用して、スタンドアロン・要素を中央にすることができます。イメージはインライン要素であるため、これを有効にするにはdisplay: block;も使用する必要があります。そして、要素の幅を必要とする:あなたはジュニア開発者として十分に検索されないようにしました

.hudson { 
 
    color: white; 
 
    position: relative; 
 
    font-size: 60px; 
 
    top: 105px; 
 
    font-family: Futura, 'Trebuchet MS', Arial, sans-serif; 
 
    text-align: center; 
 
} 
 
.threeD { 
 
    text-shadow: 0 1px 0 #ccc, 0 2px 0 #c9c9c9, 0 3px 0 #bbb, 0 4px 0 #b9b9b9, 0 5px 0 #aaa, 0 6px 1px rgba(0, 0, 0, .1), 0 0 5px rgba(0, 0, 0, .1), 0 1px 3px rgba(0, 0, 0, .3), 0 3px 5px rgba(0, 0, 0, .2), 0 5px 10px rgba(0, 0, 0, .25), 0 10px 10px rgba(0, 0, 0, .2), 0 20px 20px rgba(0, 0, 0, .15); 
 
} 
 
.p1 { 
 
    position: relative; 
 
    text-align: center; 
 
    top: 70px; 
 
    text-align: center; 
 
    -webkit-animation-delay: 1s; 
 
} 
 
.p2 { 
 
    position: relative; 
 
    text-align: center; 
 
    top: 80px; 
 
    text-align: center; 
 
    -webkit-animation-delay: 1s; 
 
} 
 
.p3 { 
 
    position: relative; 
 
    text-align: center; 
 
    top: 90px; 
 
    text-align: center; 
 
    -webkit-animation-delay: 1s; 
 
} 
 
.coding { 
 
    display: block; 
 
    margin-left: auto; 
 
    margin-right: auto; 
 
    max-width:125px; 
 
    max-height:125px; 
 
    padding: 10px; 
 
} 
 
.paracolor { 
 
    color: skyblue; 
 
    font-size: 25px; 
 
    font-family: Orbitron; 
 
    text-align: center; 
 
} 
 
#icons { 
 
    padding-top: 100px; 
 
    text-align: center; 
 
} 
 
#icons i { 
 
    color: white; 
 
} 
 
body { 
 
    background-image: url(PICTURES1/mountains4.jpeg); 
 
    background-repeat: no-repeat; 
 
}
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Orbitron" /> 
 
<link rel="stylesheet" type="text/css" href="fontawesome/css/font-awesome.min.css"> 
 
<img class="coding animated fadeInDown" src="PICTURES1/coding.png"> 
 
<h2 class="hudson threeD animated fadeInDown">Hudson Reamer</h2> 
 
<p class="paracolor p1 animated fadeInRightBig">blah blah blah</p> 
 
<p class="paracolor p2 animated fadeInLeftBig">blah blah blah</p> 
 
<p class="paracolor p3 animated fadeInRightBig">blah blah blah</p> 
 
<div id="icons"> 
 
    <a href="https://www.instagram.com/hreamer/"><i class="fa fa-instagram fa-4x"></i></a> 
 
    <a href="mailto:[email protected]"><i class="fa fa-envelope-o fa-4x"></i></a> 
 
    <a href="https://twitter.com/search?q=%40hreamer&src=typd&lang=en"><i class="fa fa-twitter fa-4x"></i></a> 
 
</div>

+0

本当に助けてくれてありがとう!良い一日を過ごしてください! – CookieM

0

に思えます。あなたがGoogleを持っている場合、これを行う方法はいくつかあります。

だけ追加

パディング:0 0 0 47%;

あなたのimgタグスタイル。

<img class="coding animated fadeInDown" src="PICTURES1/coding.png" style="padding: 0 0 0 47%; max-width:125px;max-height:125px;"> 
+0

コメントとフィードバックをありがとう!助けて頂きました。 – CookieM

関連する問題