2016-10-06 5 views
1

私は自分のウェブサイトの小さな「ニュース」タブを作っていますが、divの最後までボーダーラインが必要ですこれは、それは私が入れているテキストを過ぎて行く意味ならば、これはすべてのニュースラインのために起こる、現在、私はdivのが、私の最後まで行く必要があり、私が定義されている。このdivの末尾まで下の境界線が続きます(テキストが続かなくても)

.news { 
width: 50%; 
height: 40%; 
background-color: #FFF; 
float: right; 
margin-top: 50px; 
margin-right: 60px; 
} 

.news a { 
text-decoration: none; 
color: #000; 
font-size: 21px; 
} 

.news p a { 
content: ""; 
padding-bottom: 1%; 
border-bottom: 2px solid #000; 
} 

.news image { 
/* Nothing */ 
} 

のborder-bottomを試してみましたこれを達成するために離れて見つけることができなかったので、私はこれが可能かどうか疑問に思っていた

* { 
 
    margin: 0; 
 
    padding: 0; 
 
    min-width: 1px; 
 
    min-height: 1px; 
 
} 
 
html, 
 
body { 
 
    width: 100%; 
 
    height: 115%; 
 
    overflow-x: hidden; 
 
    background-image: url('../img/bg.jpg'); 
 
} 
 
header { 
 
    margin-top: 2%; 
 
    background-color: #FF0000; 
 
    margin-left: 12.1%; 
 
    width: 75%; 
 
    height: 180px; 
 
} 
 
header p { 
 
    font-size: 64px; 
 
    margin-left: 40%; 
 
    padding-top: 4.5%; 
 
} 
 
#nav { 
 
    margin-left: 12.1%; 
 
    width: 75%; 
 
    height: 50px; 
 
    background-color: #FF0000; 
 
    border-bottom: 1px solid #FFFFFF; 
 
} 
 
#nav ul li a { 
 
    display: inline-block; 
 
    text-align: center; 
 
    padding: 11px 14px; 
 
    text-decoration: none; 
 
    font-size: 24px; 
 
} 
 
#content { 
 
    margin-left: 12.1%; 
 
    width: 75%; 
 
    height: 73.9%; 
 
    background-color: #FF0000; 
 
} 
 
.news { 
 
    width: 50%; 
 
    height: 40%; 
 
    background-color: #FFF; 
 
    float: right; 
 
    margin-top: 50px; 
 
    margin-right: 60px; 
 
} 
 
.news a { 
 
    text-decoration: none; 
 
    color: #000; 
 
    font-size: 21px; 
 
} 
 
.news p a { 
 
    content: ""; 
 
    padding-bottom: 1%; 
 
    border-bottom: 2px solid #000; 
 
} 
 
.news image { 
 
    /* I am not sure what to do here just yet */ 
 
} 
 
#form { 
 
    padding-top: 10%; 
 
    width: 100%; 
 
    text-align: center; 
 
    display: block; 
 
} 
 
#form label { 
 
    font-size: 25px; 
 
    border: none; 
 
} 
 
#form input { 
 
    width: 30%; 
 
    height: 30px; 
 
    margin-bottom: 2%; 
 
} 
 
#form input[type=text], 
 
input[type=password] { 
 
    border: 1px solid #FFFFFF; 
 
    border-radius: 2%; 
 
} 
 
#form input[type=text], 
 
input[type=password] { 
 
    outline: none; 
 
} 
 
#form input[type=submit] { 
 
    background-color: #006099; 
 
    border: 1px solid #006099; 
 
} 
 
#form input[type=submit]:focus { 
 
    background-color: #005099; 
 
    outline: none; 
 
} 
 
#form label p { 
 
    color: #11FF00; 
 
} 
 
.downloadable { 
 
    text-align: center; 
 
    padding-top: 80px; 
 
} 
 
.downloadable a {} .downloadable a img { 
 
    width: 40%; 
 
} 
 
.downloadable a img:hover { 
 
    -webkit-filter: blur(1px); 
 
    -moz-filter: blur(1px); 
 
    -o-filter: blur(1px); 
 
    -ms-filter: blur(1px); 
 
    filter: blur(1px); 
 
} 
 
footer { 
 
    text-align: center; 
 
    background-color: #FF9900; 
 
    width: 75%; 
 
    margin-left: 12.1%; 
 
} 
 
#nav #right { 
 
    float: right; 
 
} 
 
#nav ul { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    width: 100%; 
 
    border-top: 1px solid #FFFFFF; 
 
} 
 
#nav ul li { 
 
    float: left; 
 
} 
 
#nav ul a:hover { 
 
    transition: 0.5s; 
 
    background-color: #FFFF0F; 
 
} 
 
#login { 
 
    display: none; 
 
    float: right; 
 
    margin-top: 2%; 
 
    margin-right: 5%; 
 
    width: 25%; 
 
    height: 20%; 
 
    border: 1px solid #444444; 
 
    background-color: #FFFFFF; 
 
} 
 
#login form { 
 
    margin-left: 15%; 
 
    margin-top: 8%; 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <title>Website</title> 
 
    <link rel="stylesheet" type="text/css" href="css/style.css" /> 
 
</head> 
 

 
<body> 
 
    <header> 
 
    <p>Lost Story</p> 
 
    </header> 
 
    <div id="nav"> 
 
    <ul> 
 
     <li><a href="index.php">Home</a> 
 
     </li> 
 
     <?php if(!isset($_COOKIE[ 'LoggedIn'])) { echo "<li><a href=\"register.php\ ">Register</a></li>"; } ?> 
 
     <li><a href="downloads.php">Downloads</a> 
 
     </li> 
 
     <li><a href="forums.php">Forums</a> 
 
     </li> 
 
     <li><a href="donate.php">Donate</a> 
 
     </li> 
 
     <li><a href="vote.php">Vote</a> 
 
     </li> 
 
     <div id="right"> 
 
     <?php if(isset($_COOKIE[ 'LoggedIn']) && !empty($_COOKIE[ 'LoggedIn'])) { echo "<li><a href=\"php/logout.php\ ">Log Out</a></li>"; } else { echo "<li><a href=\"login.php\ ">Log in</a></li>"; } ?> 
 
     </div> 
 
    </ul> 
 
    </div> 
 
    <div id="content"> 
 
    <div class="news"> 
 
     <p><a href="location-to-news.php">This is a test</a> 
 
     </p> 
 

 
    </div> 
 
    </div> 
 
    <footer>Website made by Lucas Ouwens</footer> 
 
</body> 
 

 
</html>

+1

JSFiddleへのリンクや、視覚的にあなたの問題を表示するために何かを含めることをお勧めします。 – markbernard

+0

HTMLを提供して、これがどのように見えるかを知ることができます。 – Santi

+0

@markbernardこれを追加しました。 –

答えて

0

border-bottomは、あなたがそれをinline表示(デフォルトdisplay)を有し、コンテンツの幅を取る適用するa要素として最後まで行きません。

display: block.news p aを追加すると、幅全体に拡張されます。

乾杯!以下

スニペット:

* { 
 
    margin: 0; 
 
    padding: 0; 
 
    min-width: 1px; 
 
    min-height: 1px; 
 
} 
 
html, 
 
body { 
 
    width: 100%; 
 
    height: 115%; 
 
    overflow-x: hidden; 
 
    background-image: url('../img/bg.jpg'); 
 
} 
 
header { 
 
    margin-top: 2%; 
 
    background-color: #FF0000; 
 
    margin-left: 12.1%; 
 
    width: 75%; 
 
    height: 180px; 
 
} 
 
header p { 
 
    font-size: 64px; 
 
    margin-left: 40%; 
 
    padding-top: 4.5%; 
 
} 
 
#nav { 
 
    margin-left: 12.1%; 
 
    width: 75%; 
 
    height: 50px; 
 
    background-color: #FF0000; 
 
    border-bottom: 1px solid #FFFFFF; 
 
} 
 
#nav ul li a { 
 
    display: inline-block; 
 
    text-align: center; 
 
    padding: 11px 14px; 
 
    text-decoration: none; 
 
    font-size: 24px; 
 
} 
 
#content { 
 
    margin-left: 12.1%; 
 
    width: 75%; 
 
    height: 73.9%; 
 
    background-color: #FF0000; 
 
} 
 
.news { 
 
    width: 50%; 
 
    height: 40%; 
 
    background-color: #FFF; 
 
    float: right; 
 
    margin-top: 50px; 
 
    margin-right: 60px; 
 
} 
 
.news a { 
 
    text-decoration: none; 
 
    color: #000; 
 
    font-size: 21px; 
 
} 
 
.news p a { 
 
    content: ""; 
 
    padding-bottom: 1%; 
 
    border-bottom: 2px solid #000; 
 
    display: block; 
 
} 
 
.news image { 
 
    /* I am not sure what to do here just yet */ 
 
} 
 
#form { 
 
    padding-top: 10%; 
 
    width: 100%; 
 
    text-align: center; 
 
    display: block; 
 
} 
 
#form label { 
 
    font-size: 25px; 
 
    border: none; 
 
} 
 
#form input { 
 
    width: 30%; 
 
    height: 30px; 
 
    margin-bottom: 2%; 
 
} 
 
#form input[type=text], 
 
input[type=password] { 
 
    border: 1px solid #FFFFFF; 
 
    border-radius: 2%; 
 
} 
 
#form input[type=text], 
 
input[type=password] { 
 
    outline: none; 
 
} 
 
#form input[type=submit] { 
 
    background-color: #006099; 
 
    border: 1px solid #006099; 
 
} 
 
#form input[type=submit]:focus { 
 
    background-color: #005099; 
 
    outline: none; 
 
} 
 
#form label p { 
 
    color: #11FF00; 
 
} 
 
.downloadable { 
 
    text-align: center; 
 
    padding-top: 80px; 
 
} 
 
.downloadable a {} .downloadable a img { 
 
    width: 40%; 
 
} 
 
.downloadable a img:hover { 
 
    -webkit-filter: blur(1px); 
 
    -moz-filter: blur(1px); 
 
    -o-filter: blur(1px); 
 
    -ms-filter: blur(1px); 
 
    filter: blur(1px); 
 
} 
 
footer { 
 
    text-align: center; 
 
    background-color: #FF9900; 
 
    width: 75%; 
 
    margin-left: 12.1%; 
 
} 
 
#nav #right { 
 
    float: right; 
 
} 
 
#nav ul { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    width: 100%; 
 
    border-top: 1px solid #FFFFFF; 
 
} 
 
#nav ul li { 
 
    float: left; 
 
} 
 
#nav ul a:hover { 
 
    transition: 0.5s; 
 
    background-color: #FFFF0F; 
 
} 
 
#login { 
 
    display: none; 
 
    float: right; 
 
    margin-top: 2%; 
 
    margin-right: 5%; 
 
    width: 25%; 
 
    height: 20%; 
 
    border: 1px solid #444444; 
 
    background-color: #FFFFFF; 
 
} 
 
#login form { 
 
    margin-left: 15%; 
 
    margin-top: 8%; 
 
}
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <title>Website</title> 
 
    <link rel="stylesheet" type="text/css" href="css/style.css" /> 
 
</head> 
 

 
<body> 
 
    <header> 
 
    <p>Lost Story</p> 
 
    </header> 
 
    <div id="nav"> 
 
    <ul> 
 
     <li><a href="index.php">Home</a> 
 
     </li> 
 
     <?php if(!isset($_COOKIE[ 'LoggedIn'])) { echo "<li><a href=\"register.php\ ">Register</a></li>"; } ?> 
 
     <li><a href="downloads.php">Downloads</a> 
 
     </li> 
 
     <li><a href="forums.php">Forums</a> 
 
     </li> 
 
     <li><a href="donate.php">Donate</a> 
 
     </li> 
 
     <li><a href="vote.php">Vote</a> 
 
     </li> 
 
     <div id="right"> 
 
     <?php if(isset($_COOKIE[ 'LoggedIn']) && !empty($_COOKIE[ 'LoggedIn'])) { echo "<li><a href=\"php/logout.php\ ">Log Out</a></li>"; } else { echo "<li><a href=\"login.php\ ">Log in</a></li>"; } ?> 
 
     </div> 
 
    </ul> 
 
    </div> 
 
    <div id="content"> 
 
    <div class="news"> 
 
     <p><a href="location-to-news.php">This is a test</a> 
 
     </p> 
 

 
    </div> 
 
    </div> 
 
    <footer>Website made by Lucas Ouwens</footer> 
 
</body> 
 

 
</html>

1
10は、代わりにこれをするあなたの .news p aセクションを変更し

<a>よう

.news p a { 
    content: ""; 
    padding-bottom: 1%; 
    border-bottom: 2px solid #000; 
    display: block; 
    width: 100%; 
} 

インライン要素はその内容と同じ幅になります。 <a>display: block;に変更すると、その幅を好みに合わせて変更できます。この場合、私はあなたがwidth: 100%;を望んでいると信じています。

0

おそらく、あなたがそれをそれのために時間タグを使用して、スタイルができますか?このライン、(赤のライン)は、以下を参照してください:

<hr style="border-top: 2px solid; background-color: #ff0000; color:#ff0000"> 

* { 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t min-width: 1px; 
 
\t min-height: 1px; 
 
\t } 
 

 
html,body { 
 
\t width: 100%; 
 
\t height: 115%; 
 
\t overflow-x: hidden; 
 
\t background-image: url('../img/bg.jpg'); 
 
\t } 
 

 

 

 
header { 
 
\t margin-top: 2%; 
 
\t background-color: #FF0000; 
 
\t margin-left: 12.1%; 
 
\t width: 75%; 
 
\t height: 180px; 
 
} 
 

 
header p { 
 
\t font-size: 64px; 
 
\t margin-left: 40%; 
 
\t padding-top: 4.5%; 
 
} 
 

 
#nav { 
 
\t margin-left: 12.1%; 
 
\t width: 75%; 
 
\t height: 50px; 
 
\t background-color: #FF0000; 
 
\t border-bottom: 1px solid #FFFFFF; 
 
} 
 

 
#nav ul li a { 
 
\t display: inline-block; 
 
\t text-align: center; 
 
\t padding: 11px 14px; 
 
\t text-decoration: none; 
 
\t font-size: 24px; 
 
\t } 
 
\t 
 
#content { 
 
\t margin-left: 12.1%; 
 
\t width: 75%; 
 
\t height: 73.9%; 
 
\t background-color: #FF0000; 
 
} 
 

 
.news { 
 
\t width: 50%; 
 
\t height: 40%; 
 
\t background-color: #FFF; 
 
\t float: right; 
 
\t margin-top: 50px; 
 
\t margin-right: 60px; 
 
} 
 

 
.news a { 
 
\t text-decoration: none; 
 
\t color: #000; 
 
\t font-size: 21px; 
 
} 
 

 
.news p a { 
 
\t content: ""; 
 
\t padding-bottom: 1%; 
 
\t border-bottom: 2px solid #000; 
 
} 
 

 
.news image { 
 
\t /* I am not sure what to do here just yet */ 
 
} 
 

 

 
#form { 
 
\t padding-top: 10%; 
 
\t width: 100%; 
 
\t text-align: center; 
 
\t display: block; 
 
\t 
 
} 
 

 
#form label { 
 
\t font-size: 25px; 
 
\t border: none; 
 
\t } 
 

 
#form input { 
 
\t width: 30%; 
 
\t height: 30px; \t 
 
\t margin-bottom: 2%; 
 
} 
 

 
#form input[type=text], input[type=password] { 
 
\t border: 1px solid #FFFFFF; 
 
\t border-radius: 2%; 
 
} 
 

 
#form input[type=text], input[type=password] { 
 
\t outline: none; 
 
} 
 

 
#form input[type=submit] { 
 
\t background-color: #006099; 
 
\t border: 1px solid #006099; 
 
} 
 

 
#form input[type=submit]:focus { 
 
\t background-color: #005099; 
 
\t outline: none; 
 
} 
 

 
#form label p { 
 
\t color: #11FF00; 
 
} 
 

 
.downloadable { 
 
\t text-align: center; 
 
\t padding-top: 80px; 
 

 
} 
 

 
.downloadable a { 
 

 
} 
 

 
.downloadable a img { 
 
\t width: 40%; 
 
} 
 

 
.downloadable a img:hover { 
 
-webkit-filter: blur(1px); 
 
-moz-filter: blur(1px); 
 
-o-filter: blur(1px); 
 
-ms-filter: blur(1px); 
 
filter: blur(1px); 
 

 
} 
 

 
footer { 
 
\t text-align: center; 
 
\t background-color: #FF9900; 
 
\t width: 75%; 
 
\t margin-left: 12.1%; 
 
} 
 

 
#nav #right { 
 
\t float: right; 
 
} 
 

 
#nav ul { 
 
\t list-style-type: none; 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t width: 100%; 
 
\t border-top: 1px solid #FFFFFF; 
 
\t 
 
} 
 

 
#nav ul li { 
 
\t float: left; 
 
} 
 

 
#nav ul a:hover { 
 
\t transition: 0.5s; 
 
\t background-color: #FFFF0F; 
 
} 
 

 
#login { 
 
\t display: none; 
 
\t float: right; 
 
\t margin-top: 2%; 
 
\t margin-right: 5%; 
 
\t width: 25%; 
 
\t height: 20%; 
 
\t border: 1px solid #444444; 
 
\t background-color: #FFFFFF; 
 
} 
 

 
#login form { 
 
\t margin-left: 15%; 
 
\t margin-top: 8%; 
 
}
<!DOCTYPE html> 
 
<html> 
 
\t <head> 
 
\t \t <title>Website</title> 
 
\t \t <link rel="stylesheet" type="text/css" href="css/style.css"/> 
 
\t </head> 
 
\t <body> 
 
\t \t <header><p> Lost Story </p></header> 
 
\t \t \t \t <div id="nav"> 
 
\t \t \t <ul> 
 
\t \t \t \t <li><a href="index.php">Home</a></li> 
 
\t \t \t \t <?php 
 
\t \t \t \t if(!isset($_COOKIE['LoggedIn'])) { 
 
\t \t \t \t echo "<li><a href=\"register.php\">Register</a></li>"; 
 
\t \t \t \t } 
 
\t \t \t \t ?> 
 
\t \t \t \t <li><a href="downloads.php">Downloads</a></li> 
 
\t \t \t \t <li><a href="forums.php">Forums</a></li> 
 
\t \t \t \t <li><a href="donate.php">Donate</a></li> 
 
\t \t \t \t <li><a href="vote.php">Vote</a></li> 
 
\t \t \t \t \t <div id="right"> 
 
\t \t \t \t \t <?php 
 
\t \t \t \t \t \t if(isset($_COOKIE['LoggedIn']) && !empty($_COOKIE['LoggedIn'])) { 
 
\t \t \t \t \t \t echo "<li><a href=\"php/logout.php\">Log Out</a></li>"; 
 
\t \t \t \t \t \t } else { 
 
\t \t \t \t \t \t \t echo "<li><a href=\"login.php\">Log in</a></li>"; 
 
\t \t \t \t \t \t } 
 
\t \t \t \t \t ?> 
 
\t \t \t \t \t </div> 
 
\t \t \t </ul> 
 
\t \t </div> 
 
\t \t <div id="content"> 
 
\t \t \t <div class="news"> 
 
       <p> 
 
        <a href="location-to-news.php">This is a test</a> 
 
        <hr style="border-top: 2px solid; background-color: #ff0000; color: #ff0000"> 
 
       </p> 
 
\t \t \t </div> 
 
\t \t </div> 
 
\t <footer> Website made by Lucas Ouwens </footer> 
 
\t </body> 
 
</html>

関連する問題