こんにちは。
web初心者です。
今、jqueryを使いスライドショーを作っているのですが
上手く行きません。
5枚の画像を重ねてフェードイン フェードアウトみたいな形にしてるのですが、最後の画像だけdisplay: none;が適用されなくてきれいに表示出来ません。
どなたか詳しい方、宜しくお願い致します。
<HTML>
<div id="contents">
<div class="slideshow">
<img src="top30.jpg" width="950" height="450">
<img src="top21.jpg" width="950" height="450" class="alt">
<img src="top20.jpg" width="950" height="450" class="alt">
<img src="top22.jpg" width="950" height="450" class="alt">
<img src="top23.jpg" width="950" height="450" class="alt">
</div>
</div>
<CSS>
#contents {
width: 950px;
margin-right: auto;
margin-left: auto;
height: auto;
.slideshow {
width: 950px;
border-top-width: 1px;
border-top-style: solid;
clear: both;
padding-top: 60px;
height: auto;
position: relative;
float: left;
}
.slideshow img {
position: absolute;
}
.slideshow img .alt {
display: none;
}
No.2ベストアンサー
- 回答日時:
ごめんなさい、ようやく意図がつかめました。
.slideshow img .alt → .slideshow .alt
もしくは、
.slideshow img .alt → .slideshow img.alt // スペースが余分です。
本当に単純なミスで申し訳ございませんでした。
スペースが入るとか入らないとか細かい事がわかってません。
ありがとうございました。
また、宜しくお願いします。
No.1
- 回答日時:
説明文だけでは、どこに問題があるかわかりませんので、書いたプログラムを提示していただけないでしょうか?
この回答への補足
補足します。
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>LAZY</title>
<link href="style.css" rel="stylesheet" type="text/css">
<!-- デスクトップ -->
<link href="desktop.css" rel="stylesheet" type="text/css" media="only screen and (min-width:950px)">
<script src="jquery-1.8.3.min.js"></script>
<script src="index.js"></script>
<!--[if lt IE 9]>
<script src="dist/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div id="container">
<h1><a href="index.html"><img src="img1.jpg" width="150" height="160" alt="lazy" onmouseover="this.src='img2.jpg';" onmouseout="this.src='img1.jpg'" /> </a></h1>
<div id="nav">
<ul>
<li><a href="concept.html">CONCEPT</a></li>
<li><a href="style.html">STYLE&GALLERY</a></li>
<li><a href="http://ameblo.jp/lazy84/">BLOG</a></li>
<li><a href="contact.html">CONTACT</a></li>
</ul>
</div></div>
<div id="contents">
<div class="slideshow">
<img src="top30.jpg" width="950" height="450">
<img src="top21.jpg" width="950" height="450" class="alt">
<img src="top20.jpg" width="950" height="450" class="alt">
<img src="top22.jpg" width="950" height="450" class="alt">
<img src="top23.jpg" width="950" height="450" class="alt">
</div>
</div>
</body>
</html>
<CSS>
@charset "UTF-8";
/* CSS Document */
h1 {
border-bottom-style: none;
border-top-style: none;
border-right-style: none;
border-left-style: none;
margin-bottom: 40px;
float: left;
padding-top: 50px;
}
p {
font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif;
font-size: 14px;
line-height: 24px;
}
#contents {
width: 950px;
margin-right: auto;
margin-left: auto;
height: auto;
}
#container {
padding-top: 0px;
padding-right: 0px;
padding-bottom: 10px;
padding-left: 0px;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
width: 950px;
}
body {
font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "メイリオ", Meiryo, Osaka, "MS Pゴシック", "MS PGothic", sans-serif;
font-size: 14px;
background-image: url(img6.jpg);
}
#nav ul {
list-style-type: none;
padding-left: 0px;
margin-top: 0px;
padding-top: 0px;
padding-bottom: 0px;
width: 950px;
}
#nav ul li {
float: left;
border-right-width: 0px;
border-right-style: none;
border-top-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-style: none;
border-bottom-style: none;
border-left-style: none;
}
#nav ul li a:hover {
color: #F00;
}
#nav ul li a {
font-size: 14px;
color: #FFF;
text-decoration: none;
width: 160px;
text-align: center;
display: block;
line-height: 45px;
margin-top: 150px;
background-color: #666;
margin-left: 10px;
}
#nav li a {
background-image: -moz-linear-gradient(top,#888 0%, #777 50%, #666
50%, #777 100%);
}
#nav li a{
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #555), color-stop(0.50, #444), color-stop(0.50, #333), color-stop(1, #444)); text-shadow:0 -1px 0px #333
,0 1px 0px #555
}
#nav li:first-child a{
border-radius:5px 0 0 5px;
}
#nav li:last-child a{
border-radius:0 5px 5px 0;
}
.slideshow {
width: 950px;
border-top-width: 1px;
border-top-style: solid;
border-top-color: #000;
border-right-color: #000;
border-bottom-color: #000;
border-left-color: #000;
clear: both;
padding-top: 60px;
height: auto;
position: relative;
float: left;
}
.slideshow img {
position: absolute;
}
.slideshow img .alt {
display: none;
}
$(function(){
var interval = 3000;
$('.slideshow').each(function(){
var container = $(this);
function switchImg(){
var imgs = container.find('img');
var first = imgs.eq(0);
var second = imgs.eq(1);
first.fadeOut().appendTo(container);
second.fadeIn();
}
setInterval(switchImg,interval);
});
});
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
似たような質問が見つかりました
- JavaScript jQueryでのドラッグアンドドロップについて 1 2022/07/30 09:10
- HTML・CSS ヘッダーの画像にメインエリアがかぶってしまいます 1 2022/11/28 14:06
- HTML・CSS CSSのホバーエフェクト 1 2023/06/19 06:53
- HTML・CSS CSSが効かずどのように指定すれば良いか分からないのでアドバイスお願い致します 2 2023/06/07 12:25
- HTML・CSS 【HTML】【CSS】【Swiper】 元の画像は横1200×縦600なのですが、実際のサイト上に反 5 2022/07/16 13:57
- HTML・CSS img と p を縦中央に配置したいのですがうまくいきません。 2 2023/01/12 14:38
- HTML・CSS 吹き出し 下記の吹き出しのスタイルシートについて 下記のスタイルシートは左側にアイコンがでる使用にな 1 2022/11/12 17:55
- HTML・CSS 書籍を見つつサイト造りの練習をしているのですが、見た目が一致しません 2 2022/11/28 15:00
- JavaScript html5に変えるとスライドショーが消えてしまった。 3 2022/03/26 19:53
- JavaScript vertical sliderをautoplayしたい 2 2022/08/25 14:47
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
ボタンをセル内一杯に表示させ...
-
【HTML/CSS】ボタンの枠が伸び...
-
htmlでキャラクター画像を、サ...
-
リンクを知らせる手のマークが...
-
htmlで画像を2個ずつ並べていき...
-
画像の場合のみ、下線を消す方...
-
table で画像をピッタリとくっ...
-
同一URLの連続アクセス方法
-
ホームページで画像を横に並べ...
-
htmlの文字が縦書きになる
-
HTML属性での「""」 「''」違い
-
超音波で洗脳。
-
css初心者 フレックスボックス...
-
【ヒトの神秘】美男美女から何...
-
widthやheightの数値に単位(px...
-
複数のボタンを等間隔に、かつ...
-
質問1.
-
Macで画像の切り抜きできないの?
-
画像にリンクを張ると画像がず...
-
<h1>、<h2>と<p><div>の行間を...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
ボタンをセル内一杯に表示させ...
-
リンクを知らせる手のマークが...
-
UDP通信を使うチャットプログラ...
-
ポップアップウィンドウのサイ...
-
プルダウンの選択リストの中に...
-
htmlで画像を2個ずつ並べていき...
-
ホームページビルダーの画像サ...
-
XML画像データををHTMLで簡単に...
-
画像のサイズが変わらない
-
画像の場合のみ、下線を消す方...
-
リンクを選択したときの青い枠...
-
レスポンシブ対応のHTML・CSS(...
-
footerの背景が切れて、背景画...
-
html+CSSのみで作るスライドショー
-
ホームページタグ打ち。サイズ...
-
画像の横に文字をうまく配置で...
-
水面の波紋
-
ホームページで画像を横に並べ...
-
【HTML/CSS】ボタンの枠が伸び...
-
HTMLのIMAGEに。。
おすすめ情報