Lucas Ouwens Lucas Ouwens - 2 months ago 10
CSS Question

A bottom border line till the end of the div, even if the text does not continue

I am making a small 'news' tab for my website, i however want to have a border line until the end of the div, even if this means it goes past the text i have put, this would happen for every news line, currently i have tried this

.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 */
}


the border-bottom that i have defined should go until the end of the div but i haven't been able to find away to accomplish this, so i was wondering if this was possible to do or not



* {
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>




Answer

The border-bottom does not go till the end as the a element to which you apply it has inline display (default display) and takes the width of the content.

Add display: block to .news p a and it will extend to the whole width.

Cheers!

Snippet below:

* {
  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>