ショボ短歌会

HTML、cssに詳しい方、助言お願いします。 footerの部分なのですが、footerより上の部分(サイドのナビやメイン部分)にj Query、javascriptを入れる(入れたのはアコーディオン)と、footerの部分がおかしくなります(footerのbackground-colorが一部消えるなど)
どなたか、もしおかしい部分があるのでしたら、おかしい部分の指摘をお願いします。xxxはテキストを入れている部分です。

footerのHTML

<div class="footercolor clearfix">
<div id="footer">
<div class="footerbox1">
<ul class="footertext1">
<li><a href="../ranking.html">xxx</a></li>
<li><a href="../area-top/area.html">xxx</a></li>
</ul></div>

<div class="footerbox2">
<ul class="footertext2">
<li><a href="../index.html">xxx</a></li>
<li><a href="../site.html">xxx</a></li>
<li><a href="../info.html">xxx</a></li>
<li><a href="../system.html">xxx</a></li>
</ul></div>

<div class="footerbox3">
<ul class="footertext3">
<li><a href="../inquiry.html">xxx</a></li>
</ul></div>

</div>

<address class="copyright">Copyright (C) xxx.com 2014 All Rights Reserved.</address>


footerのcss

.footercolor{
background-color:#FFCC99;


}

#footer{
width:960px;
margin:0 auto;


}

.footerbox1{
width:320px;
float:left;

}

.footerbox2{
width:320px;
float:left;

}

.footerbox3{
width:320px;
float:left;

}

.footertext1{
text-align:center;
margin-top:12px;
list-style:none;
padding:3px;

}

.footertext2{
margin-top:12px;
list-style:none;
padding:3px;
text-align:left;
margin-left:80px;
}

.footertext3{
text-align:center;
margin-top:12px;
list-style:none;
padding:3px;
margin-left:50px;

}

.footertext1 a:hover{
filter:alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;

}

.footertext2 a:hover{
filter:alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;

}

.footertext3 a:hover{
filter:alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;

}

.copyright{
clear:both;
text-align:center;
font-weight:bold;
padding-top:50px;
padding-bottom:10px;
}

A 回答 (2件)

そうですか・・


>根本的な部分(divの閉じタグ)が無かったのでおかしくなっていました。
 むやみにDIV使うからです。HTMLが汚くなっちゃいますし、メンテナンスできなくなりますよ。DIVは
「DIV要素とSPAN要素は、id属性及び class属性と併用することで、文書に構造を付加するための一般機構を提供する。( http://www.asahi-net.or.jp/%7Esd5a-ucd/rec-html4 … )」ものであって、デザインのためではありません。
 HTML5では、安易にDIVは使えなくなります。
Note:Authors are strongly encouraged to view the div element as an element of last resort, for when no other element is suitable.( http://www.w3.org/TR/html5/grouping-content.html … )
 著者は他に適切な要素がないときの最後の最後の手段としてdiv要素を使用することを強く推奨する。・・

 また、スタイルシートのセレクタの書き方も見直されたほうが良いでしょう。
サンプルを一度表示してご覧なさい。
div.footer ul,div.footer p{}
と書いてあるのは、「footerブロック内(半角スペース)のul要素と、p要素は」と言う意味です。これを見るだけでHTML見なくても、なにをデザインしているか分かりますよね。
    • good
    • 0

 なんというか・・jqueryにしろjavascriptにしろ、配布されている物は結構古いものが多くて、ちょっと手を加えようとすると色々な部分が競合して色々な問題が発生します。


 与えられた情報の範囲では原因は分かりません。

 まずHTMLをstrictで、CSSを基本に忠実に作成してシンプルにして分かりやすくすることが慣用です。ざっと見る限りHTMLは
<div class="footer">
 <ul>
  <li><a href="../ranking.html">xxx</a></li>
  <li><a href="../area-top/area.html">xxx</a></li>
 </ul>
 <ul>
  <li><a href="../index.html">xxx</a></li>
  <li><a href="../site.html">xxx</a></li>
  <li><a href="../info.html">xxx</a></li>
  <li><a href="../system.html">xxx</a></li>
 </ul>
 <p><a href="../inquiry.html">xxx</a></p>
 <address>Copyright (C) xxx.com 2014 All Rights Reserved.</address>
</div>
だけでよいはずです。セレクタはHTMLの文書構造を元に書けば良い。そうすると通常は詳細度は期待通りになる。

 そのうえで、原因を特定すれば良いです。多分、より詳細度のもので上書きされているとか・・

[サンプル]
★Another HTML Lint - Gateway( http://www.htmllint.net/html-lint/htmllint.html )
 で検証済みのHTML4.01strict + CSS2.1 + CSS3のopacity
★スマホ(480px以上に対応してます)リキッド!!
★タブは_に置換してあるので戻す。
<!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:470px;max-width:900px;margin:0 auto;padding:5px;}
div.footer{
background-color:#FFCC99;
padding:0;
margin:0 auto;
font-size:0;
text-align:center;
}
div.footer ul,div.footer p{
list-style:none;
display:inline-block;
width:30%;
margin:0;padding:0;
font-size:18px;
}
div.footer ul{
line-height:20px;
height:20px;
overflow:hidden;
}
div.footer ul:hover{
overflow:visible;
}
div.footer ul li{margin:0;padding:0;}
div.footer ul:hover,div.footer p:hover{opacity: 0.5;}
address{font-size:18px;font-weight:bold;padding:50px 0 10px 0;}
-->
_</style>
</head>
<body>
_<div class="header">
__<h1>タイトル</h1>
__<p>このページでは・・・・</p>
_</div>
_<div class="section">
__<h2>見出し</h2>
__<p>本文はsection</p>
__<div class="section">
___<h3>項見出し</h3>
___<p>本文項記事</p>
___<p>sectionの階層でレベルが判断される</p>
__</div>
__</div>
_</div>
_<div class="footer">
__<ul>
___<li><a href="../ranking.html">xxx1</a></li>
___<li><a href="../area-top/area.html">xxx2</a></li>
__</ul>
__<ul>
___<li><a href="../index.html">xxx3</a></li>
___<li><a href="../site.html">xxx4</a></li>
___<li><a href="../info.html">xxx5</a></li>
___<li><a href="../system.html">xxx6</a></li>
__</ul>
__<p><a href="../inquiry.html">xxx</a></p>
__<address>Copyright (C) xxx.com 2014 All Rights Reserved.</address>
_</div>
</body>
</html>
    • good
    • 0
この回答へのお礼

ありがとうございます。せっかく教えていただいたのですが、根本的な部分(divの閉じタグ)が無かったのでおかしくなっていました。すみません

お礼日時:2014/08/27 18:58

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!