-1

ホバー属性を持つ 3 つの画像があり、それは私の Web サイトの別のページへのハイパーリンクとして機能します。ただし、3つの画像を同じ行に配置する方法がわかりません。コードを含むjsFiddleページを次に示します。

HTML:

<div class="view view-sixth" style="margin-bottom:30px">
     <img src="champions/mode/ashe.jpg">
     <div class="mask">
     <h2>1</h2>
     <p>1</p>
         <a href="http://www.google.com" class="info" target="_blank">Google</a>
     </div>
</div>

<div class="view view-sixth" style="margin-bottom:30px">
     <img src="champions/mode/garen.jpg">
     <div class="mask">
     <h2>2</h2>
     <p>2</p>
         <a href="http://www.google.com" class="info" target="_blank">Google</a>
     </div>
</div>


<div class="view view-sixth" style="margin-bottom:30px">
     <img src="champions/mode/ryze.jpg">
     <div class="mask">
     <h2>3</h2>
     <p>3</p>
          <a href="http://www.google.com" class="info" target="_blank">Google</a>
     </div>
</div>

CSS:

.view-sixth img {
   -webkit-transition: all 0.4s ease-in-out 0.5s;
   -moz-transition: all 0.4s ease-in-out 0.5s;
   -o-transition: all 0.4s ease-in-out 0.5s;
   -ms-transition: all 0.4s ease-in-out 0.5s;
   transition: all 0.4s ease-in-out 0.5s;

}
.view-sixth .mask {
   background: rgba(146,96,91,0.5);
   -ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
   filter: alpha(opacity=0);
   opacity: 0;
   -webkit-transition: all 0.2s ease-in 0.2s;
   -moz-transition: all 0.2s ease-in 0.2s;
   -o-transition: all 0.2s ease-in 0.2s;
   -ms-transition: all 0.2s ease-in 0.2s;
   transition: all 0.2s ease-in 0.2s;

}
.view-sixth h2 {
   -ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
   filter: alpha(opacity=0);
   opacity: 0;
   background: transparent;
   margin: 20px 40px 0px 40px;
   -webkit-transform: scale(10);
   -moz-transform: scale(10);
   -o-transform: scale(10);
   -ms-transform: scale(10);
   transform: scale(10);
   -webkit-transition: all 0.3s ease-in-out 0.1s;
   -moz-transition: all 0.3s ease-in-out 0.1s;
   -o-transition: all 0.3s ease-in-out 0.1s;
   -ms-transition: all 0.3s ease-in-out 0.1s;
   transition: all 0.3s ease-in-out 0.1s;

}
.view-sixth p {
   -ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
   filter: alpha(opacity=0);
   opacity: 0;
   -webkit-transform: scale(10);
   -moz-transform: scale(10);
   -o-transform: scale(10);
   -ms-transform: scale(10);
   transform: scale(10);
   -webkit-transition: all 0.3s ease-in-out 0.2s;
   -moz-transition: all 0.3s ease-in-out 0.2s;
   -o-transition: all 0.3s ease-in-out 0.2s;
   -ms-transition: all 0.3s ease-in-out 0.2s;
   transition: all 0.3s ease-in-out 0.2s;

}
.view-sixth a.info {
   -ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
   filter: alpha(opacity=0);
   opacity: 0;
   -webkit-transform: translateY(100px);
   -moz-transform: translateY(100px);
   -o-transform: translateY(100px);
   -ms-transform: translateY(100px);
   transform: translateY(100px);
   -webkit-transition: all 0.3s ease-in-out 0.1s;
   -moz-transition: all 0.3s ease-in-out 0.1s;
   -o-transition: all 0.3s ease-in-out 0.1s;
   -ms-transition: all 0.3s ease-in-out 0.1s;
   transition: all 0.3s ease-in-out 0.1s;

}
.view-sixth:hover .mask {
   -ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
   filter: alpha(opacity=100);
   opacity: 1;
   -webkit-transition-delay: 0s;
   -moz-transition-delay: 0s;
   -o-transition-delay: 0s;
   -ms-transition-delay: 0s;
   transition-delay: 0s;


}
.view-sixth:hover img {
   -webkit-transition-delay: 0s;
   -moz-transition-delay: 0s;
   -o-transition-delay: 0s;
   -ms-transition-delay: 0s;
   transition-delay: 0s;


}
.view-sixth:hover h2 {
   -ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
   filter: alpha(opacity=100);
   opacity: 1;
   -webkit-transform: scale(1);
   -moz-transform: scale(1);
   -o-transform: scale(1);
   -ms-transform: scale(1);
   transform: scale(1);
   -webkit-transition-delay: 0.1s;
   -moz-transition-delay: 0.1s;
   -o-transition-delay: 0.1s;
   -ms-transition-delay: 0.1s;
   transition-delay: 0.1s;

}
.view-sixth:hover p {
   -ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
   filter: alpha(opacity=100);
   opacity: 1;
   -webkit-transform: scale(1);
   -moz-transform: scale(1);
   -o-transform: scale(1);
   -ms-transform: scale(1);
   transform: scale(1);
   -webkit-transition-delay: 0.2s;
   -moz-transition-delay: 0.2s;
   -o-transition-delay: 0.2s;
   -ms-transition-delay: 0.2s;
   transition-delay: 0.2s;

}
.view-sixth:hover a.info {
   -ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
   filter: alpha(opacity=100);
   opacity: 1;
   -webkit-transform: translateY(0px);
   -moz-transform: translateY(0px);
   -o-transform: translateY(0px);
   -ms-transform: translateY(0px);
   transform: translateY(0px);
   -webkit-transition-delay: 0.3s;
   -moz-transition-delay: 0.3s;
   -o-transition-delay: 0.3s;
   -ms-transition-delay: 0.3s;
   transition-delay: 0.3s;

}

.view {
   width: 260px;
   height: 390px;
   border:  solid purple;
   position: relative;
   text-align: center;
   box-shadow: 1px 1px 2px purple;
   cursor: default;


}
.view .mask,.view .content {
   width: 260px;
   height: 390px;
   position: absolute;
      background: rgba(0, 0, 0, 0.7);
   overflow: hidden;
   top: 0;
   left: 0;

}
.view img {
   display: block;
   position: relative;

}
.view h2 {
   text-transform: uppercase;
   color: white;
   text-align: center;
   position: relative;
   font-family: Candara;
   font-size: 20px;
   padding: 30px;
}
.view p {
   font-family: Candara, serif;
   font-size: 20px;
   position: relative;
   color: white;
   padding: 10px 20px 20px;
   text-align: center;
}
.view a.info {
   display: inline-block;
   text-decoration: none;
   padding: 7px 14px;
   background: white;
   color: black;
   text-transform: uppercase;
   -webkit-box-shadow: 0 0 1px #000;
   -moz-box-shadow: 0 0 1px #000;
   box-shadow: 0 0 1px #000;
   border-radius: 5px;
}
.view a.info:hover {
   -webkit-box-shadow: 0 0 5px #000;
   -moz-box-shadow: 0 0 5px #000;
   box-shadow: 0 0 5px #000;
}

誰かが私にいくつかの指針を与えることができますか?


編集:ご回答いただきありがとうございます。私の問題は修正されました。:D

4

5 に答える 5

1

ルール セットに追加float: left;します。.view

.view {
   width: 260px;
   height: 390px;
   border: solid #800080;
   position: relative;
   text-align: center;
   box-shadow: 1px 1px 2px #800080;
   cursor: default;
   float: left; /* ← add this */
}

固定の jsFiddle

于 2013-07-10T16:15:04.060 に答える
0

画像を含む のCSSdisplayプロパティを次のように設定します。divinline-block

.view {
    display: inline-block;
}

jsフィドル

十分なスペースがある場合は、画像を配置する必要があります。十分なスペースがない場合でも画像を常に整列させたい場合は、画像をコンテナーに含めて、コンテナーの を設定しmin-widthます。

于 2013-07-10T16:15:10.017 に答える
0

これを追加することにより:

.view-sixth {
    display:inline-block;
width:33%;    
}

それは私のために問題を解決しました:D

于 2013-07-10T16:10:16.340 に答える
0

ビュー クラス ルールに追加します。float:left;

jsFiddle の例

于 2013-07-10T16:11:43.127 に答える
0

必要なのはfloat: leftdiv.viewだけです

見てください - http://jsfiddle.net/8P7rB/

.view {
   width: 260px;
   height: 390px;
   border:  solid purple;
   position: relative;
   text-align: center;
   box-shadow: 1px 1px 2px purple;
   cursor: default;
    float: left;
    margin-right: 10px;
}
于 2013-07-10T16:11:45.707 に答える