CSSで画像を同じ位置に重なり合わせる方法

このQ&Aのポイント
  • CSSで画像を同じ位置に重なり合わせる方法について説明します。
  • z-indexとposition:relativeを使用することで、画像を重ねて配置することができます。
  • 画像の配置時に生じる空きをなくす方法についても解説します。
回答を見る
  • ベストアンサー

CSSで画像を同じ位置に重なり合わせるには?

お世話になります。 2枚のTOP画像(一枚は差し替え可能なJPG、もう一枚はその画像の上に位置するフレーム枠のような役割を果たすGIF画像)をぴったり重ね合わせて配置したいと考えています。 調べたところz-indexという方法があるらしく、position:relativeしてtop,left指定でいろいろ試してみたのですが、上に重なる画像の分だけ、下部コンテンツに空きが出ます。(添付画像のような現象です) これはCMS化して画像を差し替える時のためにページなのですが、こういう現象をなくして普通のWebサイトページのように配置することはできないのでしょうか? 素人ゆえおかしな質問しているかもしれませんが、どうかご教授お願いします。 現時点のHTML/CSSはこんな感じです。 HTML--- <div id="contens"> <div id="top_img_a"> <p class="img_top"><img src="images/dammy_img02.jpg" alt="新規投稿ダミー画像" /></p> <p class="flame"><img src="images/new_entries_img_flame.gif" alt="新規投稿フレーム枠" /></p> </div> CSS---(本意ではありませんが、やむなくtop,left調整で位置を作っている段階です。) #top_img_a { width:900px; margin:0; padding:0; position:relative; top:0px; } .img_top { position:relative; z-index:1; top:0; left:25px; } .flame { position:relative; z-index:2; top:-216px; left:25px; }

  • CSS
  • 回答数4
  • ありがとう数4

質問者が選んだベストアンサー

  • ベストアンサー
  • ORUKA1951
  • ベストアンサー率45% (5062/11036)
回答No.4

>調べているうちに気が付いたのですが、sectionプロパティもnavプロパティも >HTML5のみの対応で、  きちんと正確に!!。 「sectionプロパティもnavプロパティ」じゃありません。 ・section要素、nav要素はHTML5から採用される要素です。  文書は色々な要素で組み立てていて、それをタグを用いてどの要素かを示します。  p要素は、それでマークされていれば、囲まれた部分がp要素であることを示します。 ・HTML4では、文書構造を示す要素が不足していたため、class名やIDをつけていました。 『DIV要素とSPAN要素は、id属性及び class属性と併用することで、文書に構造を付加するための一般機構を提供する。 ( http://www.asahi-net.or.jp/%7Esd5a-ucd/rec-html401j/struct/global.html#h-7.5.4 )』 ・・・top_img_a,img_top,flameというclass名じゃ、おかしいでしょ。そもそも、まったく必要ないのですよ。  私は原則として、class名にHTML5で登場する要素名を使用しています。それは先でHTML5でページを作成するときに、スムーズに移項できるからですし、本来、HTML4でも望まれる名前だからです。  ですから、別にHTML4.01だろうが、XHTML1.0だろうが、class名として使うなら問題ありません。  ただし、HTML4.01であってもXHTML1.0であっても、必ずstrictで作らなきゃダメです。  もしくはXHTML1.1。なぜなら、HTML4.01の勧告(1999/12)以来、 『著者 ・・・【中略】・・・  HTML文書を作る場合には、この仕様における、他のDTDセットではなく strict DTD に適合する文書を作るよう推奨する。 ( http://www.asahi-net.or.jp/%7Esd5a-ucd/rec-html401j/conform.html#h-4.1 )』 となっていたはずです。予告どおり、XHTML1.1HTML5では、transotinalな要素、属性は削除されています。 ★Another HTML-lint gateway ( http://openlab.ring.gr.jp/k16/htmllint/htmllint.html ) ★W3C CSS 検証サービス ( http://jigsaw.w3.org/css-validator/#validate_by_input ) 最後に、検証済みのソースを示しておきます。スタイルシートなしで表示してもよい。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="ja"> <head> _<meta http-equiv="content-type" content="text/html; charset=Shift_JIS"> _<title>サンプル</title> _<meta name="author" content="ORUKA1951"> _<meta http-equiv="Content-Style-Type" content="text/css"> _<link rev="made" href="mailto:oruka1951@hoge.com" title="send a mail" > _<link rel="START" href="../index.html"> _<style type="text/css" media="screen"> <!-- html,body{margin:0;} div.header,div.section,div.footer,div.footer div.nav{ _width:720px;margin:0 auto; _border:solid 1px silver; } div.header{ _height:200px; _margin-bottom:40px; _background-color:silver; _border-color:silver; } div.section{ _background-color:fuchsia; _border-color:fuchsia; } div.footer div.nav{ _position:absolute;top:200px;height:40px; _font-family:"MS Pゴシック", "ヒラギノ角ゴ Pro W3", sans-serif; _line-height:40px; _text-align:center; _background-color:black; } div.footer ul,div.footer ul li{ _display:block;list-style:none; _margin:0;padding:0; } div.footer ul li{ _width:118px;float:left; _position:relative; } div.footer ul li a{ _display:block; _width:100%;height:100%; _text-decoration:none; _color:#FFF; } div.footer ul li ul{ _font-size:75%; _position:absolute;top:40px;left:0; _display:none; } div.footer ul li ul li{ _height:60px;width:140px; _background-image:url(../images/dawnmenu_button.gif); } div.footer ul li:hover{ _background-color:rgb(255,160,0); } div.footer ul li ul li:hover{ _background-color:transparent; } div.footer ul li ul li a{ _padding-top:20px; } div.footer ul li:hover ul{ _display:block; } div.footer{ _background-color:yellow; _border-color:yellow; } div.section p,div.section h2,div.section dl{ _width:680px;margin:0 auto; } div.section p.sample img{ _display:block; _margin:0 auto;padding:5px; _background-image:url(images/new_entries_img_flame.gif) } --> _</style> </head> <body> _<div class="header"> __<h1>サンプル</h1> _</div> _<div class="section"> __<h1>サンプル2</h1> __<div class="section"> ___<p class="sample"><img src="images/dammy_img02.jpg" width="480" height="360" alt="サンプル画像"></p> ___<h2>用意する画像</h2> ___<dl> ____<dt>images/dammy_img02.jpg</dt> ____<dd>480px巾、360px高さの画像を用意する。</dd> ____<dt>images/new_entries_img_flame.gif</dt> ____<dd>内寸480×360pxが透明な枠用画像</dd> ____<dt>../images/dawnmenu_button.gif</dt> ____<dd>巾140,高60pxの吹き出し画像</dd> ___</dl> __</div> _</div> _<div class="footer"> __<h2>文書情報</h2> __<div class="nav"> ___<ul> ____<li><a href="/">TOP</a></li> ____<li><a href="./profile">会社情報</a> _____<ul> ______<li><a href="./profile/index.html">会社概要</a></li> ______<li><a href="./profile/office.html">営業所</a></li> _____</ul> ____</li> ____<li><a href="./B">Bボタン</a></li> ____<li><a href="./C">Cボタン</a></li> ____<li><a href="./D">Dボタン</a></li> ____<li><a href="./E">Eボタン</a></li> ___</ul> __</div> _</div> </body> </html>

toonie
質問者

お礼

いつも詳しく検証用のソースも書いてくださり感謝します。 アドバイスをもとに思う通りに実装することができました。 基本から勉強していこうと思います。 ありがとうございました。

その他の回答 (3)

  • ORUKA1951
  • ベストアンサー率45% (5062/11036)
回答No.3

>そのドロップボタンが今回絶対は位置した2つの画像の下に表示され、隠れてしまいます。  一番良い解決方法は、 ドロップダウンメニューを作るこのCSSどこが変? - Webデザイン・CSS - 教えて!goo ( http://okwave.jp/qa/q7229595.html )  で示したように、ナビゲーションをページの最後に記述することです。  ナビゲーションは、HTMLの文書構造上、本文の前にあるのは変です。  今回のrelative内でabsoluteさせる方法も、本来の方法ではなくあくまで抜け道です。いずれの問題も、「文書構造に従ったHTMLを作成しない」「デザインのためにHTMLを書く」と言うのが、本当の原因なのです。 ドロップダウンメニューを作るこのCSSどこが変? - Webデザイン・CSS - 教えて!goo ( http://okwave.jp/qa/q7229595.html )で示した、サンプルソースの<div class="section">内に、先の回答の <div class="section"> <p class="sample"><img src="images/dammy_img02.jpg" alt="新規投稿ダミー画像" width="480" height="360" alt="サンプル画像" /></p> <h2>記事の見出し</h2> <p>段落</p> </div>  を入れた場合、問題は起きないはずです。  最初にHTMLを書くとき、デザインのことは一切考えずに、ひたすら文書構造をマークアップすることに徹して、その後スタイルシートでデザインするという開発方法にするのが良いです。

toonie
質問者

お礼

回答ありがとうございます。 調べているうちに気が付いたのですが、sectionプロパティもnavプロパティもHTML5のみの対応で、現在私が記述しているDOCTYPE宣言のXHTML1.0には非対応みたいですね。 うーん、困りましたね、そうしたらいいのでしょうか。

  • ORUKA1951
  • ベストアンサー率45% (5062/11036)
回答No.2

 上に重ねる画像を、position:relative;の親コンテナブロック内でposition:absoluteで配置すれば良いですし、後から登場するものなのでz-indexも不要です。 #top_img_a{ width:900px;margin:0;padding:0;margin:0 auto; position:relative; } #top_img_a p{margin:0;paddin:0;} #top_img_a p.flame{ position:absolute;top:-5px;left:-5px; } ★まず参考にすべきは仕様書です。 9.3.1 配置体系を選択する ( http://www.swlab.it.okayama-u.ac.jp/man/rec-css2/visuren.html#choose-position ) のrelativeには、 「ボックスの位置はまず通常フローにて計算され(この計算で得られた位置を通常位置と呼ぼう)、その通常位置から相対的に配置される。なお、あるボックスBが相対配置される場合、それに後行するボックスの位置は、Bが相対配置されていないかのように計算される。」 ★しかし、もっとも基本的な部分で間違っています。  HTMLは、あくまで文書構造を示すもので、スタイルシートはそのデザインをするためのものです。 【引用】____________ここから 文書の構造をプレゼンテーションと切り離すことで広汎なプラットフォームや多様なメディアでの文書提供コストを低下でき、文書の改訂も容易になるということが、経験的に知られている。  ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ここまで[HTML4.01仕様書2.4.1 構造とプレゼンテーションの分離( http://www.asahi-net.or.jp/%7Esd5a-ucd/rec-html401j/intro/intro.html#h-2.4.1 )]より  質問文だけでは、それぞれの文書内での構造的意味合いがわからないのですが、示された二つの画像は、文書内ではまったく意味のないもの、あるいは、最初の画像は単なるサンプルかもしれません。  後者だとするとHTML上は <div class="section"> <p class="sample"><img src="images/dammy_img02.jpg" alt="新規投稿ダミー画像" width="480" height="360" alt="サンプル画像" /></p> <h2>記事の見出し</h2> <p>段落</p> </div> とかになるはずです。スタイルシートも画像も読み込まないユーザーエージェントや検索エンジンでも意味がわかるように記述すると言うことです。 ★枠の画像は、線幅5pxとして画像サイズ+10pxのものを用意したとします。  そのうえでスタイルシートで div.section{width:900px;margin:0 auto;} p.sample img{ display:block; margin:0 auto;padding:5px; background-image:url(images/new_entries_img_flame.gif) }  HTMLもCSSも極めてわかりやすく、書くのが簡単になるでしょう。  そしてなによりも、HTMLがデザインと独立していますから、先でどのようにもデザインを変えることが出来ます。  ためしに、最初のものをスタイルシートなしで表示したものと比べてみてください。これがまさにHTMLとCSSの役割分担です。 div.section{width:900px;margin:0 auto;} p.sample img{ display:block; margin:0 auto;padding:5px; background-image:url(images/new_entries_img_flame.gif) } #top_img_a{ width:900px;margin:0;padding:0;margin:0 auto; position:relative; } #top_img_a p{margin:0;paddin:0;} #top_img_a p.flame{ position:absolute;top:-5px;left:-5px; } <body> <h1>サンプル1</h1> <div id="contens"> <div id="top_img_a"> <p class="img_top"><img src="images/dammy_img02.jpg" alt="新規投稿ダミー画像" /></p> <p class="flame"><img src="images/new_entries_img_flame.gif" alt="新規投稿フレーム枠" /></p> <h2>記事の見出し</h2> <p>段落</p> </div> <h1>サンプル2</h1> <div class="section"> <p class="sample"><img src="images/dammy_img02.jpg" alt="新規投稿ダミー画像" width="480" height="360" alt="サンプル画像" /></p> <h2>記事の見出し</h2> <p>段落</p> </div> </body>

toonie
質問者

お礼

いつも詳しく回答くださり本当に感謝致します。一番簡単なposition:relative;の親コンテナブロック内でposition:absoluteしたところ思う通りに配置できました。ありがとうございます。 ひとつ疑問なのですが、その上部のheaderのボタン類にはドロップダウンメニューが<ul><li>によって配置されhover時に表示されるようになっているのですが(その問題に関してもORUKA1951様に回答いただきありがとうございます)そのドロップボタンが今回絶対は位置した2つの画像の下に表示され、隠れてしまいます。ボタン類は画像の上部に表示させたいのですが...この問題の原因はなんでしょうか。 よければ教えてください。

noname#163110
noname#163110
回答No.1

これでどうですか? (contents→containerにして、下の文章をcontentsにしてます。) relative内でabsolute指定していくんだったと思いますが・・ 【html】 <div id="container"> <div id="top_img_a"> <p class="img_top"><img src="images/dammy_img02.jpg" alt="新規投稿ダミー画像" /></p> <p class="flame"><img src="images/new_entries_img_flame.gif" alt="新規投稿フレーム枠" /></p> </div> <div id="contents"> <p>下の文章</p> </div> </div> 【css】 #container{ position:relative; margin:0 auto; width:900px; } #top_img_a{ width:900px; height:●px;//高さを入力 position:relative; } .img_top { position:absolute; z-index:1; top:0px; left:25px; } .flame { position:absolute; z-index:2; top:0px; left:25px; } #contents{ position:relative; }

toonie
質問者

お礼

回答ありがとうございます。ちょっと思うような形になりませんでしたが、感謝致します。

関連するQ&A

  • CSSにてfloat:leftを使用して画像を3つ並べたのですが。。

    CSSにてfloat:leftを使用して画像を3つ並べたのですがこの3つの画像をセンターによせることができません。 なんでかまったくわかりません(ToT) 教えてくださいm(__)m 【HTML】 <div class="box2"><img src="images/sum2.gif"></div> <div class="box3"><img src="images/sum3.gif"></div> <div class="box4"><img src="images/sum4.gif"></div> 【CSS】 .box2{ float:left; width:219px; } .box3{ float:left ; width:156px;} .box4{ float:left ; width:195px; }

  • CSSのdivで、ページ全体をセンタリング出来ない

    質問させて頂きます。 <style type="text/css"> #contena { margin-right: 10px; margin-left: 10px; text-align: center; height: 900px; width: 950px; } </style></head> というように、全体をdivで囲んだにもかかわらず、何故かセンタリング出来ません。 最も簡単に、このページをセンタリングするには、どうすればよいでしょうか? ホームページビルダーで「どこでも配置モード」で作ったものを、dreamweaverで作り直す場合に該当します。 下記にHTMLを記載しておきます。 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=shift_jis"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta name="IBM:HPB-Input-Mode" content="mode/flm; pagewidth=750; pageheight=900"> <meta name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 14.0.8.0 for Windows"> <title>タイトル</title> <style type="text/css"> #contena { margin-right: 10px; margin-left: 10px; text-align: center; height: 900px; width: 950px; } </style></head> <body background="blue_p7b.gif"> <div id="contena"> <div style="top : 0px;left : 20px; position : absolute; z-index : 20; " id="Layer22"><img src="anim.gif" width="373" height="93" border="0" alt="ようこそ"></div> <div style="top : 18px;left : 575px; position : absolute; z-index : 2; " id="Layer4"><a href="http://www.dodgeball.or.jp/"><img src="jdba1.gif" border="0" width="106" height="30"></a></div> <div style="top : 60px;left : 143px; position : absolute; z-index : 1; " id="Layer1"><img src="logo111.gif" width="488" height="69" border="0" alt="リンク"></div> <div style="top : 219px;left : 317px; position : absolute; z-index : 27; width : 580px; height : 51px; " id="Layer28"> <p><font color="#0000ff" size="+2">コンテンツ</font></p> </div> <div style="top : 161px;left : 647px; position : absolute; z-index : 22; " id="Layer23"></div> <div style="top : 255px;left : 284px; position : absolute; z-index : 28; " id="Layer2"><img src="frendlyindx.gif" width="546" height="410" border="0"></div> <div style="top : 216px;left : 652px; position : absolute; z-index : 23; " id="Layer24"></div> <div style="top : 304px;left : 50px; position : absolute; z-index : 26; " id="Layer27"></div> <div style="top : 754px;left : 47px; position : absolute; z-index : 19; width : 707px; height : 154px; " id="Layer21"><iframe frameborder="1" src="saishijoho.html" width="709" height="150" scrolling="AUTO"></iframe></div> <div style="top : 953px;left : 40px; position : absolute; z-index : 7; " id="Layer9"><a href="taikaikekka.html"><img src="button41.gif" width="57" height="54" border="0" alt=" "></a></div> <div style="top : 659px;left : 48px; position : absolute; z-index : 6; " id="Layer8"><img src="logo1.gif" width="194" height="65" border="0" alt="最新情報 "></div> <div style="top : 1020px;left : 34px; position : absolute; z-index : 12; </div> </body> </html> 詳しい方がいましたら、よろしくお願いします。

  • 【CSS】画像を重ねたいのですが動きません

    ウェブサイトを作っているのですが、 positionを使って、ひとの写真と影の画像を重ねたいのですが、影がピクリとも動いてくれません。 ちなみに他のスタイルはCSSから読み込めているので、 CSSのインポートエラーではないようです。 難しいことをしているわけではないと思いつつも、 二時間くらいここで止まっておりまして、悲しいです・・・。 下記のコードを書いております。 ご教示頂ければ幸いです。 よろしくお願いいたします。 ☆HTML <div id="staffphoto"> <img src="写真.jpg" width="160" border="0"> <img src="影.gif" border="0" width="160" class="shadow"> </div> ☆CSS #staffphoto{   position: relative; } #staffphoto img.shadow{   position: absolute;   top: 5px;   left: 5px; }

    • ベストアンサー
    • CSS
  • IE6,7で画像の上に載せた文字がずれる

    HTMLなのですが、 画像が縦に3つつながって1つの画像のようになった状態で表示しようとしています。 さらに上と下の画像にはテキストを上にかぶせて表示します。 画像全体にリンクを貼ってあります。 下記のようなコードで作成した所、IE6,7でのみ、下記のバグが出てしまいました。 ・画像とテキストの縦位置のズレ ・画像間に2px程度の空白が生じる ・画像に設定したリンクが開かない 大変困っています。 どなたか原因と修正方法を教えていただけますでしょうか。 <a href="test.html"> <div style="position: relative; width: 183px; height: 265px; "> <img src="images/top.jpg" width="183" height="36" /> <div style="position: absolute; top: -11px; left: 55px;" class="font16b"> <p align="center">text1</p> </div> <img src="images/main.jpg" width="183" height="193" border="0" /> <img src="images/bottom.jpg" width="183" height="36" /> <div style="position: absolute; top: 218px; left: 4px; width: 181px;" class="font13"> <p align="left">text2</p> </div> </div> </a>

    • ベストアンサー
    • CSS
  • 画像を重ねて表示する方法を知りたいです。

    おせわになっております。 下記のようなソースを作りました。 ------------------------------------------------- <div style="position: relative;"> <img src="sideback.gif" width="182" height="812" alt="sideback"> <div style="position: absolute; top: 30px; left: 15px;"> <span style="position:absolute; top:10px; left:10px"><img src="sidemanu-canner.gif" alt="メニュー"> </span> </div> </div -------------------------------------------------- 画像を重ねたいんですが、firefoxでプレビューすると (IEでも同じです。) 下の画像(背景)の上に上の画像が表示されるはずだった場所に四角い3つぐらい色のついたマークがでて (IEは小さな資格に×マーク) 上に表示されるはずだった画像が表示できません どうしたらいいでしょうか?

    • ベストアンサー
    • HTML
  • ウィンドウの縮小に合わせて変化させるには?

    WEBデザインの質問です。 添付画像のようなものを作りたいのですが、ウインドウの幅を小さくした時に、 自動的にそれに合わせて画像も小さくなってもらいたのですができません。 どのようにhtml,cssを書いたらいいですか? 画像4の上に、画像1,2,3があって、背景、画像1,2,3がメニュー(後で画像にリンクを追加したい)のようなイメージです。 そこで今、画像4は縮小に合わせて一緒に縮んでくれるのですが、 画像1,2,3は色々試してみたのですが変化がありません。 html↓ <body> <article> <div class="relative"> <img src="/../../画像4.gif" class="img-responsive" alt="" /> <img src="/../../画像1.gif" alt="" class="absolute" /> <img src="/../../画像2.gif" alt="" class="absolute2" /> <img src="/../../画像3.gif" alt="" class="absolute3" /> </div> </article> </body> CSS↓ @charset "utf-8"; .img-responsive { display: block; max-width: 100%; height: auto; } .relative { position: relative; } .absolute { position: absolute; top: 515px; left: 185px; } .absolute2 { position: absolute; top: 515px; left: 535px; } .absolute3 { position: absolute; top: 515px; left: 888px; } 初めてhtmlを書いているので、変な質問をしていたらすみません。 お早めな回答をいただけると助かります。 よろしくお願いいたします。

    • ベストアンサー
    • CSS
  • 画像の四隅を丸くしたい

    html初心者です。 あるメイン画像の左上に、透過gif画像を重ねて表示させたいのですが、そのようなことは可能なんでしょうか・・・ メイン画像は長方形です(通常の画像のように、ふちは角ばっている)。その画像の左上に、透過gif画像を重ねて表示させようとしています。 htmlには: <TABLE>  <TR>   <TD>    <div id="corner"><IMG SRC="images/frame4_03.gif"></div>    <div id="inner"><IMG SRC="screen05_04.jpg"></div>   </TD>  </TR> </TABLE> cssには: #corner{ position:absolute; left:251px; top:98px; width:99px; height:39px; BACKGROUND-COLOR:#FFFFFF; } #inner{ position:absolute; left:251px top:98px; width:999px; height:799px; } と書いています。 WindowsXP、IE7で表示させています。 よろしくおねがいいたします。

    • ベストアンサー
    • HTML
  • FireFoxで画像がずれます

    ホームページビルダーでHPを作成しました。IEで動作確認後、FireFoxで見ると、 画像がの位置が設定と違います。画像が上にずれているんです。どうしてそうなるのでしょう?どなたか教えてください 記述は <DIV style="top : 929px;left : 35px; position : absolute; z-index : 6; " id="Layer5"><IMG src="0161.gif" width="82" height="33" border="0"></DIV> です。 よろしくお願いします。

    • ベストアンサー
    • HTML
  • left (right) プロパティについて

    次のように、ベース画像の上に別の画像をのせて表示させています。 <style> <!-- .box { position:relative; left:50%; } .baseimage { position:relative; z-index:1; left:-225px; } .image1 { position:relative; z-index:2; left:-100px; top:-200px; } .image2 { position:relative; z-index:2; left:-100px; top:-300px; } --> </style> <div class="box"> <img src="baseimage.jpg" class="baseimage"> <img src="image1.jpg" width="30" height="30" class="image1"> <img src="image2.jpg" width="30" height="30" class="image2"> </div> このとき、image1 と image2 の左端からの距離が一致せず、ずれてしまいます。 それは何故なのでしょうか? コーディングに問題があるのでしょうか? お教えいただけると幸いです。よろしくお願いいたします。

    • ベストアンサー
    • HTML
  • 画像の上に画像

    HPでcenterで例えば600サイズの外枠をつくりその中にHPの内容を表示するようにしています。 その中のひとつの写真(jpg)の上に画像(gif)を重ねて表示したいのですがスタイルシートで位置を指定したときに下記のように指定するとその指定した部分(jpg画像の上の部分)のスペースが画像のサイズ分空いて指定したところへ画像は重なります。 その空いてしまうスペースをなくしたいのですがどうにもなりませんでした。absoluteもfixedも試しましたがこれだとウィンドウサイズによって位置がずれるようです。 <span style="position: relative; left:15px; top:455px;z-index:1;">  <img src="./images/***.gif" border="0"></span> <td><img src="./imeges/***.jpg" ></td> すごく困ってしまっています。知っている方教えてください。

専門家に質問してみよう