2016-11-09 8 views
0

2つのイメージを画面の中央に配置したいが、2つのイメージを画面の中央に配置したいが、これは学校のプロジェクトのためのものです。私はHTMLやCSSにあまり経験がありません。私の先生はそれらのディスプレイテーブルを作成するように私に言ったが、私はそれがどのように動作するかについてのヒントを与えることができるなら、私はそれがうまくいくと思います!前もって感謝します!私が他の情報を送る必要があるなら、私が上で述べたもの以外に何を入れるべきか分からないので教えてください。2つのイメージを反応的な方法で中央に配置したい

HTMLコード:

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8"> 
     <title>Correia e Figueiredo</title> 
     <link rel="stylesheet" href="css/index.css" type="text/css"/> 
     </head> 
    <body> 
    <div id="imagens"> 
     <div id="Morph1" class="images"> 
      <a href="figueiredo.html"> <img src="images/Morph1.png"> </a> 
      </div> 
      <div id="Morph2" class="images"> 
      <a href="figueiredo.html"> <img src="images/Morph2.png"> </a> 
      </div> 
    </div> 
    </body> 
</html> 

CSSコード:

`*{ 
    margin:0; 
    padding:0; 
} 

body{ 
    background-color: beige; 
} 

#imagens { 
    display: table; 
} 

#Morph1 { 
    display: table-cell; 
} 


#Morph2 { 
    display: table-cell; 
} 

.images a img { 
    border-radius: 100%; 
    width: 30%; 
    margin: 0 auto; 
    text-align: center; 
} 

.images { 
    text-align: center; 
    width:50%; 
}` 
+0

私はあなたが.imagesのためのマージンを定義することができると思います。 '.images ::第一子{ マージン:0 2ピクセル0自動; } .images :: last-child { margin:0 auto 0 2px; } ' 2枚の画像を置いている場合はうまくいきます – Banzay

+0

janky flexboxの罫線と余白を画像に使用することもできますが、既に提案されているオプションがより良いようです。 – Crowes

答えて

0

#Morph1#Morph2の両方にpaddingを使用して、この

#imagens {width:100%;} 
.images {padding: 10px} /*delete text-align: center*/ 
#Morph1 {text-align: right;} 
#Morph2 {text-align: left;} 
0

で試してみてくださいは、仕事を行います。

だけのよう:

*{ 
 
    margin:0; 
 
    padding:0; 
 
} 
 

 
body{ 
 
    background-color: beige; 
 
} 
 

 
#imagens { 
 
    display: table; 
 
} 
 

 
#Morph1 { 
 
    display: table-cell; 
 
    padding: 0 10px; 
 
    text-align: right; 
 
} 
 

 

 
#Morph2 { 
 
    display: table-cell; 
 
    padding: 0 10px; 
 
    text-align: left; 
 
} 
 

 
.images a img { 
 
    border-radius: 100%; 
 
    width: 30%; 
 
    margin: 0 auto; 
 
    text-align: center; 
 
} 
 

 
.images { 
 
    text-align: center; 
 
    width:50%; 
 
}
<div id="imagens"> 
 
     <div id="Morph1" class="images"> 
 
      <a href="figueiredo.html"> <img src="http://lorempixel.com/400/400"> </a> 
 
      </div> 
 
      <div id="Morph2" class="images"> 
 
      <a href="figueiredo.html"> <img src="http://lorempixel.com/400/400"> </a> 
 
      </div> 
 
    </div>

・ホープ、このことができます:以下のスニペットで

#Morph1 { 
    display: table-cell; 
    padding: 0 10px; 
    text-align: right; 
} 


#Morph2 { 
    display: table-cell; 
    padding: 0 10px; 
    text-align: left; 
} 

ルック!

0
.img { 
    display: inline-block; 
    margin-left: auto; 
    margin-right: auto; 
    height: 30px; 
} 
#images{ 
    text-align:center; 
} 

<div id="images"> 
<a href="#"> 
<img class="img" border="0" alt="" src="https://wallpapers.pub/web/wallpapers/birds-water-spray-wallpaper/3840x2160.jpg"/></a> 
<a href="#" target="_blank"> 
    <img class="img" border="0" alt="" src="http://www.gettyimages.ca/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg" /></a></div> 

リンク: - https://jsfiddle.net/ghnthrbn/

関連する問題