How to make a border bottom on the right side of the element?

774 views Asked by At

I want to apply the border to the bottom of the DIV, but it has to be on the right side of the DIV not straight under the element. This is my html and css at the moment.

<div class="vmselement"><img src="img/play.png" alt="play" />
    <h2>AFSLEELBAAR </br> OP ELD DEVICE</h2>
</div>

.vmselement{
border-bottom: 1px solid ;
color: #e8b215;

}

This is how it will looks like:

element
       border bottom

Please access FIDDLE DEMO.

4

There are 4 answers

0
Mehdi Brillaud On

Just tweak the width and thickness.

h1 {
  position: relative;
  width: 100px;
  background-color: blue;
  color: white;
}
h1::after {
  position: absolute;
  top: 0;
  right: -50%;
  content: '';
  display: block;
  height: 100%;
  width: 50%;
  border-bottom: 1px solid red;
}
<h1>Title</h1>

Edit: Edited to fit your request.

0
Barr J On

Try using margin-left or padding-left in order to change the position of the border, right now you only have border.

I can't guarantee it will work, but worth a try as I never did a border-right (so to call).

as the answer above me stated, you can tweak with the height and width also.

0
Solasido On

Not sure if that's what you're looking for but I would consider using box-shadows.

In order to do what I think you are trying to achieve, you would do something like this :

.wrapper{
    overflow:hidden;
    width:400px;
}
.vmselement{
    width:400px;
    color: #e8b215;
    box-shadow: 180px 1px 0px 0px #e8b215;
}
<div class="wrapper">
    <div class="vmselement">
        <img src="img/play.png" alt="play" />
        <h2>AFSLEELBAAR </br> OP ELD DEVICE</h2>
    </div>
</div>

That way you hide the right box-shadow, and the bottom-one is not straight under your .vmselement div.

0
Pralhad Narsinh Sonar On

Please try FIDDLE DEMO

Or else try this HTML code:

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style>
.vmselement{
color: #e8b215;
}
.color-right{
border-bottom: 1px solid #e8b215;    
width:50%; 
    float:right;
    position:relative;
}
</style>
</head>
<body>
<div class="vmselement"><img src="img/play.png" alt="play" />
    <h2>AFSLEELBAAR </br> OP ELD DEVICE</h2>
<div class="color-right">&nbsp;</div>
</div>
</body>
</html>

As you will see - I have introduced one more div which is floated to 'right' with limited width. For now I have kept the width:50%;. You may change the width as per your needs. I suggest to keep it in percentage instead in pixels.