Styling border around div - html

I'm a bit stuck on styling border around div box.
The problem is that I can't make borders not to be like:
Here is the real example what I have:
.num.num_1 {
border-left-color: #0D2431;
}
.num {
width: 60px;
height: 60px;
line-height: 50px;
border-width: 5px;
font-size: 40px;
}
.num {
float: left;
width: 40px;
height: 40px;
line-height: 36px;
text-align: center;
border: 2px solid #eee;
font-size: 20px;
color: #0D2431;
background-color: #fff;
}
div {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}
}
<div class="num num_1">1</div>

.num.cheat:before {
content:"";
position: absolute;
left: -5px;
right: -5px;
top: -5px;
bottom: -5px;
}
.num_1:before {
border-left: 5px solid black;
}
.num_2:before {
border-left: 5px solid black;
border-top: 5px solid black;
}
.num_3:before {
border-left: 5px solid black;
border-top: 5px solid black;
border-right: 5px solid black;
}
.num_4:before {
border-left: 5px solid black;
border-top: 5px solid black;
border-right: 5px solid black;
border-bottom: 5px solid black;
}
.num {
width: 60px;
height: 60px;
line-height: 50px;
border-width: 5px;
font-size: 40px;
position: relative;
margin-right: 10px;
}
.num {
float: left;
width: 40px;
height: 40px;
line-height: 36px;
text-align: center;
border: 5px solid #eee;
font-size: 20px;
color: #0D2431;
background-color: #fff;
}
div {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}
}
<div class="num num_1 cheat">1</div>
<div class="num num_2 cheat">2</div>
<div class="num num_3 cheat">3</div>
<div class="num num_4 cheat">4</div>
I modified your css a little bit. I solved it using the :before pseudo element.

Better yet, you can use box-shadow to achieve this without any extra elements.
See: http://jsfiddle.net/w3b1uh7g/2/
.num {
border-left: 0px;
box-shadow: -5px 0 0 0 #0D2431;
}

You can do a weird series of nested divs:
.border {
background: green;
padding: 10px 10px 10px 0;
display: inline-block;
}
.border-left {
padding-left: 10px;
background: black;
display: inline-block;
}
.inside-box {
background: red;
height: 100px;
width: 100px;
}
<div class="border-left">
<div class="border">
<div class="inside-box">1</div>
</div>
</div>

Just add these to your css. the Pseudo Elements should make it square without adding extra divs in the HTML
.num.num_1:before {
content: "";
position: relative;
display: block;
top: -5px;
left: -5px;
height: 5px;
width: 5px;
background: black;
}
.num.num_1:after {
content: "";
position: relative;
display: block;
bottom: 0px;
left: -5px;
height: 5px;
width: 5px;
background: black;
}

Related

How to make a speech bubble with CSS?

Is it possible to style the following HTML structure to the image shown below with CSS only?
<div class="xyz-dialog">
<div class="title"><span> Tip Title</span></div>
<div class="body"> <span>Description</span></div>
</div>
Required design:
You can do it as below if we can add a container div in the HTML:
.container{
background: gray;
padding: 16px 10px;
width:max-content;
}
.xyz-dialog {
background: white;
padding: 1rem;
border-radius: 8px;
position: relative;
width: 300px;
}
.xyz-dialog::after {
content: "";
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid white;
position: absolute;
top: 100%;
}
.body {
margin-top:8px;
color: gray;
font-size: 15px
}
<div class= "container">
<div class="xyz-dialog">
<div class="title"><span> Tip Title</span></div>
<div class="body"> <span>Description</span></div>
</div>
You can do it as below if we cannot touch the HTML structure:
.xyz-dialog {
padding: 1rem;
border-radius: 8px;
position: relative;
width: 300px;
}
.xyz-dialog::after {
content: "";
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid white;
position: absolute;
top: calc(100% -1rem);
left: 2rem;
}
.xyz-dialog::before {
content: "";
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: gray;
z-index: -1;
}
.title {
padding: 1rem;
background: white;
border-radius: 10px 10px 0 0;
margin: 0 0 -5px 0;
}
.body {
color: gray;
font-size: 15px;
background: white;
margin: 0;
padding: 1rem;
border-radius: 0 0 10px 10px;
}
<div class="xyz-dialog">
<div class="title"><span> Tip Title</span></div>
<div class="body"> <span>Description</span></div>
</div>
You can use after and border.
.xyz-dialog::after{
content: "";
border-top: 12px solid #f1f1f1;
border-right: 8px solid transparent;
border-left: 8px solid transparent;
position: absolute;
bottom: -12px;
left: 4%;
}
.xyz-dialog{
width: 50%;
background: #f1f1f1;
border-radius: 0.3em;
padding: 5px 30px;
position: relative;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
box-sizing: border-box;
flex-direction: column;
}
<div class="xyz-dialog">
<div class="title"><span> Tip Title</span></div>
<div class="body"> <span>Description</span></div>
</div>
Little late. Two Boxes. For the small noise you use the css pseudo class after.
body {
background-color: #999;
}
.wrapper {
padding:20px;
}
h3 {
margin:0;
color: #000;
}
.bubble {
position: relative;
background: white;
color: #999;
font-family: Arial;
font-size: 16px;
text-align: left;
width: 250px;
height: 120px;
border-radius: 10px;
padding: 0px;
}
.bubble:after {
content: '';
position: absolute;
display: block;
width: 0;
z-index: 1;
border-style: solid;
border-width: 0 20px 20px 0;
border-color: transparent #fff transparent transparent;
bottom: -16px;
left: 17%;
margin-left: -10px;
}
<div class="bubble">
<div class="wrapper">
<h3>title</h3>
<div>content</div>
</div>
</div>

Firefox transform:scale on hover issue

When applying transform:scale to my element, the border-colors get messed up. Would like to know if this is a known issue and has a solution? If I remove the scale the animation works fine and borders return to normal. I have also tried both ways, when scaling up and down the issue persists. Tried zoom, transform-origin, nothing seems to fix this weird issue. Also this has no issues in chrome.
JSfiddle
body {
background-color: lightblue;
}
.player-chromecast {
border: 2px solid white;
border-radius: 4px;
width: 22px;
height: 17px;
position: relative;
margin: 10px;
}
.player-chromecast:hover {
transform: scale(1.1)
}
.broadcast {
background-color: lightblue;
width: 18px;
height: 19px;
position: absolute;
bottom: -3px;
left: -2px;
}
.broadcast:after {
content: '';
height: 5px;
width: 5px;
border-top-right-radius: 20px;
position: absolute;
top: 13px;
background-color: white;
}
.reception {
border: 2px solid white;
border-bottom-color: transparent;
border-left-color: transparent;
border-top-right-radius: 20px;
position: absolute;
}
.first-bar {
height: 6px;
width: 6px;
top: 8px;
}
.second-bar {
height: 11px;
width: 11px;
top: 3px;
}
<div class="player-chromecast">
<div class="broadcast">
<div class="reception first-bar"></div>
<div class="reception second-bar"></div>
</div>
</div>
body {
background-color: #20262e;
}
h1 {
color: white;
text-align: center;
}
.player-chromecast:hover .reception {
border-bottom-color: transparent;
border-left-color: transparent;
}
p {
font-family: verdana;
font-size: 20px;
}
.player-chromecast {
border-left: 1px solid #fff !important;
border: 2px solid white;
border-radius: 4px;
width: 22px;
height: 17px;
position: relative;
margin: 10px;
border-bottom: 1px solid #fff !important;
}
.player-chromecast:hover {
transform: scale(1.1)
}
.broadcast {
background-color: #20262e;
width: 18px;
height: 19px;
position: absolute;
bottom: -3px;
left: -2px;
}
.broadcast:after {
content: '';
height: 5px;
width: 5px;
border-top-right-radius: 20px;
position: absolute;
top: 13px;
background-color: white;
}
.reception {
border: 2px solid white;
border-bottom-color: transparent;
border-left-color: transparent;
border-top-right-radius: 20px;
position: absolute;
}
.first-bar {
height: 6px;
width: 6px;
border-left: 0px;
top: 8px;
}
.second-bar {
height: 11px;
width: 11px;
border-left: 0px;
top: 3px;
}
<!DOCTYPE html>
<div class="player-chromecast">
<div class="broadcast">
<div class="reception first-bar"></div>
<div class="reception second-bar"></div>
</div>
</div>
Please check now in firefox or any other browsers it working correctly i mean border is not there on hover .....Let me know if you still get same bugs

Restyling two adjacent divs with css

I am assigned a task to design two divs like this
And here is what I have tried so far, I would like to restyle it with some css.
I would really appreciate any help with the styling. ( It doesn't have to be the same as the given image).
Thank you.
Here are my HTML and CSS code
HTML CODE:
.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.container .stage+.stage {
margin-left: 30px;
}
.stage:before {
content: "";
position: absolute;
width: 0;
height: 0;
left: 0;
border-top: 100px solid transparent;
border-left: 10px solid white;
border-bottom: 110px solid transparent;
margin: -10px 0px 0 0px;
}
.stage:after {
color: #4D81BF;
border-left: 20px solid;
border-top: 100px solid transparent;
border-bottom: 100px solid transparent;
display: inline-block;
content: '';
position: absolute;
right: -20px;
top: 0;
}
.stage {
background-color: #4D81BF;
/*width: 150px; */
height: 200px;
line-height: 40px;
display: inline-block;
position: relative;
}
.stage {
color: ;
font-weight: bold;
padding-left: 10px;
font-family: Arial;
font-size: 11;
}
#it,
#isms,
#bul {
color: white;
}
#it {
border: 3px solid white;
background-color: green;
}
#isms,
#bul {
border: 3px solid white;
background-color: orange;
}
<div class="container">
<div class="stage">
<span class="blocktext">Stage Confirm</span>
<div id="it">IT CONFIRM</div>
<div id="isms">ISMS Confirm</div>
</div>
<div class="stage">
<span class="blocktext">Stage Approve</span>
<div id="bul">Bul Approve</div>
</div>
</div>
I believe this will help you. I'd like to clean whole CSS, but didn't want to make to many changes to your original code, so you won't be confused.
.button {
width: 200px;
padding: 0 10px;
box-sizing: border-box;
}
.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.container .stage+.stage {
margin-left: 30px;
}
.stage:before {
content: "";
position: absolute;
width: 0;
height: 0;
left: 0;
border-top: 95px solid transparent;
border-left: 70px solid white;
border-bottom: 95px solid transparent;
margin: -20px 0px 0 0px;
}
.stage:after {
color: #4D81BF;
border-left: 70px solid;
border-top: 95px solid transparent;
border-bottom: 95px solid transparent;
display: inline-block;
content: '';
position: absolute;
right: -70px;
top: 0;
}
.stage {
background-color: #4D81BF;
/*width: 150px; */
height: 150px;
line-height: 40px;
display: inline-block;
position: relative;
margin: 20px;
font-weight: bold;
padding: 20px 40px 20px 100px;
font-family: Arial;
font-size: 11;
}
#it,
#isms,
#bul {
color: white;
}
#it {
border: 3px solid white;
background-color: green;
margin: 0 0 10px 0;
}
#isms,
#bul {
border: 3px solid white;
background-color: orange;
}
<div class="container">
<div class="stage">
<span class="blocktext">Stage Confirm</span>
<div id="it" class="button">IT CONFIRM</div>
<div id="isms" class="button">ISMS Confirm</div>
</div>
<div class="stage">
<span class="blocktext">Stage Approve</span>
<div id="bul" class="button">Bul Approve</div>
</div>
</div>

How to place a triangle on my div to make it look like a speech bubble?

I created a simple div for my comments section.
I would like to give it the appearance of a speech bubble by having a triangle on the left or any other effect that would make it look like a speech bubble coming from the left.
How can I achieve that without using an image ?
image
html
<div class='comment'></div>
css
.comment {
margin-left: 10px;
height: 80px;
display: inline-block;
color: white;
width: 400px;
border: 1px solid white;
padding: 10px;
border-radius: 5px;
overflow: hidden;
}
Try this
.comment {
margin-left: 10px;
height: 80px;
display: inline-block;
color: white;
width: 400px;
border: 1px solid white;
padding: 10px;
border-radius: 5px;
position: relative;
background-color: #fff;
border:1px solid #000;
}
.comment::before{
content:"";
position: absolute;
top:20px;
left:-12px;
margin:auto;
height: 20px;
width: 20px;
border:1px solid #fff;
transform:rotate(45deg);
background-color: #fff;
border-bottom:1px solid #000;
border-left:1px solid #000;
}
<div class='comment'></div>
style accordingly,
hope this helps...
I hope to help you:
.comment {
position: relative;
margin-left: 50px;
margin-top: 50px;
height: 50px;
display: inline-block;
width: 200px;
padding: 10px;
border-radius: 5px;
background: skyblue;
color: #FFF;
}
.comment:before, .comment:after {
content: '';
border-radius: 100%;
position: absolute;
width: 50px;
height: 50px;
z-index: -1;
}
.comment:after {
background-color: #fff;
bottom: -30px;
left: 55px;
}
.comment:before {
background-color: skyblue;
bottom: -20px;
left: 70px;
}
<div class='comment'>Hello,World!</div>
I like Nicholas Gallagher's work best, see his demo page.
This is lifted off his page and is not my own work.
<style>
/* Bubble with an isoceles triangle
------------------------------------------ */
.triangle-isosceles {
position: relative;
padding: 15px;
margin: 1em 0 3em;
color: #000;
background: #f3961c;
border-radius: 10px;
background:linear-gradient(#f9d835, #f3961c);
}
/* creates triangle */
.triangle-isosceles:after {
content: "";
display: block; /* reduce the damage in FF3.0 */
position: absolute;
bottom: -15px;
left: 50px;
width: 0;
border-width: 15px 15px 0;
border-style: solid;
border-color: #f3961c transparent;
}
</style>
<p class="triangle-isosceles">This is a quote. Hello world. text goes here.</p>

Regular border + offset border on button using CSS

css button with double border
I'm trying to acheive the same border effect on the button above.
The closest I can get is the following, but the bottom right corner of the bottom border is not properly rounded:
>
.login__button {
background: transparent;
border: none;
border-width: 2px 1px 2px 2px;
border-style: solid;
border-color: pink;
border-radius: 4px;
color: pink;
margin-bottom: 100px;
position: relative !important;
text-transform: uppercase;
height: 33px;
width: 102px;
box-shadow:
3.5px 4px 0px black,
1.5px 0px 0px pink,
3.5px 4px 0px black,
2px 6px 0px pink;
}
.login__button::before {
background: pink;
content: '';
position: absolute;
height: 35px;
width: 3.0px;
border-radius: 3px;
top: 3%;
right: -2.8px;
}
>
I feel like this should be possible using just box-shadows but there doesnt appear to be a way to modify the width of the box shadow to get just the black portion inset properly.
So the idea is to make the .login__button:before basically look the same as .login__button, but to change the positioning, and to give it a lower z-index than .login__button.
.login__button {
background-color: black;
border: 2px solid #FF00A0;
border-radius: 4px;
color: #FF00A0;
position: relative;
font-size: 15px;
height: 33px;
width: 102px;
cursor: pointer;
}
.login__button:before {
content: '';
background-color: black;
border: 2px solid #FF00A0;
border-radius: 4px;
position: absolute;
width: 100%;
height: 34px;
top: -2px;
left: -2px;
z-index: -1;
cursor: pointer;
box-shadow: 0 0 20px rgb(255,0,160);
}
.login__button:active {
background-color: gold;
}
.login__button:active:before {
background-color: gold;
}
<button class="login__button">LOG IN</button>
And just for the sake of it, I've added a style for then the button is pressed.
.login__button:active {
background-color: gold;
}
.login__button:active:before {
background-color: gold;
}
Here's my attempt.
.login__button {
background: black;
border: 4px solid #FF69B4;
color: #FF69B4;
position: relative;
text-transform: uppercase;
padding: 1em;
display: inline-block;
border-radius: 3px;
}
.login__button::before {
content: '';
background: black;
border: 4px solid #FF69B4;
margin-left: -4px;
position: absolute;
border-radius: 3px;
width: 100%;
height: 100%;
top: 12px;
left: 0;
z-index: -1;
}
Link
I don't know if this is what you're looking for, but here's what I'd probably do.
#a, #b{
border: 2px solid magenta;
border-radius: 4px;
}
#a{
border-top: none;
width: 20%;
box-shadow: 0 0 8px magenta;
background: linear-gradient(to bottom, magenta 0%, black 24%);
}
#b{
color: magenta;
background-color: black;
padding: 4px;
margin-bottom: 4px;
text-align: center;
}
<div id='a'>
<div id='b'>
Button
</div>
</div>
* {
box-sizing: content-box;
}
body { padding: 50px; }
.login__button {
border: 2px solid fuchsia;
border-radius: 4px;
color: fuchsia;
background: black;
text-transform: uppercase;
height: 33px;
width: 102px;
position: relative;
box-shadow: 0 8px 20px 8px rgba(227,37,243,0.3);
}
.login__button::before {
background: black;
border: 2px solid fuchsia;
content: '';
position: absolute;
border-radius: 4px;
width: 100%;
height: 5px;
bottom: -7px;
left: -2px;
}
<button class="login__button">LOG IN</button>