2016-04-27 5 views
1

enter image description here事前に私はHTMLとCSSに新しいので、私は3つの画像を中心にしたいので、私は得ることができるすべての助けていただければ幸いですが、でる。レイアウトが何であるかを見ることができるように画像を追加しました。図のフローティング画像をセンタリングする

body { 
 
\t font-family: Arial, Verdana, sans-serif; 
 
\t color: #000; 
 
\t font-weight: bold; 
 
\t margin: 0; 
 
} 
 

 
#wrapper { 
 
\t width: 100%; 
 
} 
 

 
#logo { 
 
\t float: left; 
 

 
} 
 

 
#navigation { 
 
\t clear: both; 
 
\t background-color: #14171a; 
 
\t width: 100%; 
 
\t height: 70px; 
 
\t box-shadow: 0px 5px 3px #000; 
 

 

 
} 
 

 
#navigation ul li { 
 
\t display: inline; 
 
\t margin-left: 50px; 
 

 

 
} 
 

 
#navigation ul li a { 
 
\t text-decoration: none; 
 
\t color: #fff; 
 
\t font-size: 20px; 
 
} 
 

 
#navigation ul { 
 
\t width: 570px; 
 
\t padding-top: 20px; 
 
\t margin: 0px auto 0px auto; 
 
} 
 

 
#midcontent { 
 
\t 
 
} 
 

 
h1 { 
 
\t margin: 0px auto 0px auto; 
 
\t margin-top: 50px; 
 
\t padding: 10px 0px 10px 10px; 
 
\t color: #fff; 
 
\t background-color: #6ac045; 
 
\t font-size: 170%; 
 
\t 
 
\t border-radius: 8px; 
 
\t width: 400px; 
 
} 
 

 
#midcontent article { 
 

 
\t } 
 

 
figure { 
 
    \t float: left; 
 
\t width: 300px; 
 
\t 
 
\t 
 
} 
 

 
figure img { 
 

 
\t display: inline-block; 
 
\t width: 300px; 
 
\t height: 244px; 
 
} 
 

 
figcaption { 
 
\t text-align: center; 
 
}
<!DOCTYPE html> 
 
<html> 
 
<head> 
 
\t <title>Electronix CR</title> 
 
\t <link rel="stylesheet" type="text/css" href="CSS/Electronix.css"> 
 
</head> 
 
\t <body> 
 
\t \t <div id="wrapper"> 
 
\t \t \t <header id="logo"> 
 
\t \t \t \t <img src="images/Electronix.png"> 
 
\t \t \t </header> 
 
\t \t \t <nav id="navigation"> 
 
\t \t \t \t <ul> 
 
\t \t \t \t \t <li><a href="#">Home</a></li> 
 
\t \t \t \t \t <li><a href="#">About</a></li> 
 
\t \t \t \t \t <li><a href="#">Services</a></li> 
 
\t \t \t \t \t <li><a href="#">Contact</a></li> 
 
\t \t \t \t </ul> 
 
\t \t \t </nav> 
 
\t \t \t <h1>What can we fix for you today</h1> 
 
\t \t \t <section id="midcontent"> 
 
\t \t \t \t <article class="content"> 
 
\t \t \t \t \t <figure><img src="images/Diagnostic.jpg" alt="Helianthus" /> 
 
\t \t \t \t \t <figcaption>Siagnostic</figcaption> 
 
\t \t \t \t </figure> 
 
\t \t \t \t <figure><img src="images/LCD.jpg" alt="Passiflora" /> 
 
\t \t \t \t \t <figcaption>LCD Replacement</figcaption> 
 
\t \t \t \t </figure> 
 
\t \t \t \t <figure><img src="images/Battery.jpg" alt="Nyctocalos" /> 
 
\t \t \t \t \t <figcaption>Battery Replacement</figcaption> 
 
\t \t \t \t </figure> 
 
\t \t \t \t </article> 
 
\t \t \t </section> 
 
\t \t \t 
 
\t \t </div> 
 
\t </body> 
 
</html>

+0

[別のdiv内の浮動divをセンタリング]の可能複製(http://stackoverflow.com/questions/1269245/centering-floating-divs-within-another-div)または[どのように私は中央ありません浮動小数点要素?](http://stackoverflow.com/q/4767971/5743988) – 4castle

答えて

0

あなたはブートストラップ・フレームワークを使用して問題を解決しようと試みてきましたか?グリッドを使用すると、希望のサイズに基づいて画像を列と行に配置することができます。必要に応じて

.center-block { 
    display: block; 
    margin-right: auto; 
    margin-left: auto; 
} 

は基本的にあなたがこのプロセスを繰り返します:ブートストラップだからあなたはまた、あなたのイメージにこれを追加する必要があり

<div class = row> 
    <div class = col-md-4> 
    <insert image here or content here> 
    </div> 
    </div> 

の線に沿って何かを必要とする12のグリッドで動作します。各画像は4 * 3 = 12として "col-md-4"を有する。追加の調整が必要な場合がありますが、ブートストラップはほとんどすべての重い持ち上げを行います。以下はBootStrapへのリンクとそのドキュメントです。幸運の友人。

http://getbootstrap.com/

+0

あなたの応答をありがとう、私はブートストラップは簡単な解決法です、どのように私はフレームワークを使用する代わりにこの問題を解決する方法を学びたいと思うすべての学習がナレッジへの道であることの後で、すべての私の問題を解決します。 –

+0

私はその場合、おそらくマージンの左またはマージン右を介してアライメントを手動で調整しようとしていることを理解しています。 –

+0

私は手動でコンテンツを調整する場合、小さい画面でページを呼び出すときに、中心のコンテンツはもはや中央揃えされません。 –

関連する問題