
float: leftで横に並べたら、サファリだけ隙間が空いてしまいます。
IEやファイヤーフォックスではピッタリ表示できています。
問題の箇所は以下です。
<div style="float: left;">
<p style="position: relative;">
<img src="./img/img-001.png" width="240" height="150" />
<br />
<span style="font-size: 12px; padding: 2px 5px 2px 5px; position: absolute; top: 130px; left: 0px; width: 230px; height: 16px; color: white ; background-color: black; opacity: 0.6;">テストテスト1</span>
</p>
</div>
<div style="float: left;">
<p style="position: relative;">
<img src="./img/img-002.png" width="240" height="150" />
<br />
<span style="font-size: 12px; padding: 2px 5px 2px 5px; position: absolute; top: 130px; left: 0px; width: 230px; height: 16px; color: white ; background-color: black; opacity: 0.6;">テストテスト2</span>
</p>
</div>
<div style="float: left;">
<p style="position: relative;">
<img src="./img/img-003.png" width="240" height="150" />
<br />
<span style="font-size: 12px; padding: 2px 5px 2px 5px; position: absolute; top: 130px; left: 0px; width: 230px; height: 16px; color: white ; background-color: black; opacity: 0.6;">テストテスト3</span>
</p>
</div>
どうすればサファリの隙間を消せるでしょうか?
No.2
- 回答日時:
HTML5版です。
★brは、通常の文書では登場しないはずです。
★HTMLには文書構造だけ書くようにすると、先でデザイン変えるときも楽ですし、メンテナンスも容易になります。
<!doctype html>
<html>
<head>
_<meta charset="utf-8">
_<title>サンプル</title>
_<meta name="description" content="">
_<meta name="author" content="ORUKA1951">
<style media="screen">
<!--
html,body{margin:0;padding:0;}
h1,h2,h3,h4,h5,h6{margin:0;line-height:1.6em;}
p{text-indent:1em;}
header,section,footer{width:90%;min-width:470px;max-width:900px;margin:0 auto;padding:5px;}
section section{width:auto;min-width:0px;}
/* 色 */
body{background-color:gray;}
header,section,footer{background-color:silver;}
section section{background-color:white;}
/* フロート */
section section ul{margin:1em;padding:0;}
section section ul li{list-style:none;margin:0;padding:0;float:left;position:relative;height:150px;}
section section ul li p{margin:0;position:absolute;bottom:0;width:100%;background-color:rgba(0,0,0,0.6);color:white;}
section section ul:after{content:"";white-space:pre;clear:left;display:block;}
-->
</style>
</head>
<body>
_<header>
__<h1>タイトル</h1>
__<p>このページでは・・・・</p>
_</header>
_<section>
__<h2>見出し</h2>
__<p>
___ざっと、見る限り画像リストのようですから、画像リストとしてマークアップしてあります。また、opacityだと文字まで半透明になってしまって画像の地色によったみえにくくなるので背景だけ半透明にしておきました。
__</p>
__<section>
___<ul>
____<li>
_____<img src="./img/img-001.png" width="240" height="150" alt="富士山の写真1">
_____<p>テストテスト1</p>
____</li>
____<li>
_____<img src="./img/img-002.png" width="240" height="150" alt="富士山の写真2">
_____<p>テストテスト2</p>
____</li>
____<li>
_____<img src="./img/img-003.png" width="240" height="150" alt="富士山の写真3">
_____<p>テストテスト3</p>
____</li>
___</ul>
__</section>
_</section>
_<footer>
__<h2>文書情報</h2>
__<dl class="documentHistry">
___<dt id="FIRST-PUBLISHED">First Published</dt>
___<dd>2013-03-03</dd>
__</dl>
_</footer>
</body>
</html>
No.1
- 回答日時:
通常はそのようなdivの使い方はしません。
HTML5ではさらに厳しくなって【引用】____________ここから
NOTE: Authors are strongly encouraged to view the div element as an element of last resort, for when no other element is suitable. Use of more appropriate elements instead of the div element leads to better accessibility for readers and easier maintainability for authors.
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ここまで[4.4 Grouping content — HTML5( http://www.w3.org/TR/2014/REC-html5-20141028/gro … )]より
--著者は、 他に適切な要素がないときの最後の最後の手段として div要素を使用することが強く推奨されます。div 要素の代わりにより適切な要素を使うことは、読者にとってはアクセシビリティの向上に、著者にとってメンテナンス性の向上につながります。---
※HTML4.01でも、『文書に構造を付加するため( http://www.asahi-net.or.jp/%7Esd5a-ucd/rec-html4 … )』でしたね。
とっても大事なことなので、本題とは関係ないですが念のため
さて、原因はいくつか考えられますが、最も可能性が高いのはDOCTYPE宣言によるDOCTYPE スイッチ( https://www.google.co.jp/search?q=DOCTYPE%20%E3% … )でしょう。
下記にどのブラウザも標準モードで動作するように書いたHTMLをあげて起きます。なお、HTMLは、HTML4.01strictです。時代遅れなXHTMLではありません。
『HTML文書を作る場合には、この仕様における、他のDTDセットではなく strict DTD に適合する文書を作るよう推奨する。( http://www.asahi-net.or.jp/%7Esd5a-ucd/rec-html4 … )』
★スタイルシートは、この場合は<head></head>内に書くほうが良いでしょう。
★Another HTML Lint - Gateway( http://www.htmllint.net/html-lint/htmllint.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">
_<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">
<!--
html,body{margin:0;padding:0;}
h1,h2,h3,h4,h5,h6{margin:0;line-height:1.6em;}
p{text-indent:1em;}
div.header,div.section,div.footer{width:90%;min-width:630px;max-width:900px;margin:0 auto;padding:5px;}
div.section div.section{width:auto;min-width:0;}
/* 色 */
body{background-color:gray;}
div.header,div.section,div.footer{background-color:silver;}
div.section div.section{background-color:white;}
/* フロート */
div.section div.section ul{margin:1em;padding:0;}
div.section div.section ul li{list-style:none;margin:0;padding:0;float:left;position:relative;height:150px;}
div.section div.section ul li p{margin:0;position:absolute;bottom:0;width:100%;background-color:rgba(0,0,0,0.6);color:white;}
div.section div.section ul:after{content:"";white-space:pre;clear:left;display:block;}
-->
_</style>
</head>
<body>
_<div class="header">
__<h1>タイトル</h1>
__<p>このページでは・・・・</p>
_</div>
_<div class="section">
__<h2>見出し</h2>
__<p>
___ざっと、見る限り画像リストのようですから、画像リストとしてマークアップしてあります。また、opacityだと文字まで半透明になってしまって画像の地色によったみえにくくなるので背景だけ半透明にしておきました。
__</p>
__<div class="section">
___<ul>
____<li>
_____<img src="./img/img-001.png" width="240" height="150" alt="富士山の写真1">
_____<p>テストテスト1</p>
____</li>
____<li>
_____<img src="./img/img-002.png" width="240" height="150" alt="富士山の写真2">
_____<p>テストテスト2</p>
____</li>
____<li>
_____<img src="./img/img-003.png" width="240" height="150" alt="富士山の写真3">
_____<p>テストテスト3</p>
____</li>
___</ul>
__</div>
_</div>
_<div class="footer">
__<h2>文書情報</h2>
__<dl class="documentHistry">
___<dt id="FIRST-PUBLISHED">First Published</dt>
___<dd>2013-03-03</dd>
__</dl>
_</div>
</body>
</html>
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
htmlの文字が縦書きになる
-
「dt」「dd」の内容を一列で表...
-
<div>と<div>の間の10px程の...
-
footer を横幅いっぱいに広げる...
-
CSSがなぜかfont-sizeだけ効か...
-
css初心者 フレックスボックス...
-
Flexslider2のカーセルスライダ...
-
CSSがうまくレイアウトできない...
-
CSSロールオーバーについて教え...
-
CSS上での計算を行うためのルー...
-
imgを含むliの高さが大きくなる...
-
テーブルのセル間に余白が空い...
-
CSSでボックスのheightが0になる
-
form input テキストを上下中央...
-
CSSのクラス名・ID名の指定でワ...
-
含む含まないという概念自体の...
-
リンクを知らせる手のマークが...
-
htmlのolやulなどlistにtitleや...
-
FC2ショッピングカートのカスタ...
-
<h1>、<h2>と<p><div>の行間を...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
htmlの文字が縦書きになる
-
【CSS】ヘッダーの高さが不明の...
-
widthやheightの数値に単位(px...
-
css初心者 フレックスボックス...
-
form input テキストを上下中央...
-
画像イメージの上下左右、欲し...
-
余分な縦スクロールバーが出て...
-
ページを拡大縮小でborderが消...
-
CSSがなぜかfont-sizeだけ効か...
-
表示倍率を変えるとレイアウト...
-
スクロールボックスを中央に配...
-
cssで文字サイズ指定、ptでもpx...
-
W3Cのソースコードの検証サービ...
-
投稿フォームの整列
-
<div>と<div>の間の10px程の...
-
入力フォームとセレクトボック...
-
FC2ショッピングカート 写真の...
-
divで囲まれたpaddingの指定を...
-
CSSで「overflow:scroll」をしてい
-
ネガティブマージン
おすすめ情報