how to block the message box - html

We developing chat application. in that input and out text message is coming.but input and out put is coming side by side but i need one by one.like if input is single later then that line total block then out put will come short or long text it should be come text line only but i am not able to getting that and message box corners are coming different any one please help me
This is we are facing please find screen shot
we need like this and corners are not coming same i need input user message how it is coming we need customer message box corner like that
.userTextDiv {
position: relative;
background: white;
padding-bottom: 7px;
padding-left: 7px;
padding-right: 7px;
border-radius: 6px;
border: 3px solid #999;
float: right;
margin-bottom: 7px;
font-size: 12px;
text-align: right;
padding-top: 5px;
margin-right: 4px;
margin-left: 4px;
clear: right;
}
.userTextDiv::before {
content: '';
position: absolute;
visibility: visible;
top: -3px;
right: -11px;
border: 9px solid transparent;
border-top: 11px solid #999;
}
.userTextDiv::after {
content: '';
position: absolute;
visibility: visible;
top: 0px;
right: -6px;
border: 9px solid transparent;
border-top: 8px solid white;
clear: both;
}
.userTextDiv img {
display: block;
height: auto;
max-width: 100%;
}
.userTextDiv .username {
position: relative;
display: block;
font-weight: bold;
font-size: 12px;
color: #8e0035;
}
.userTextDiv .message {
word-break: break-all;
font-size: 12px;
}
.userTextDivOp {
text-align: left;
float: left;
clear: left;
position: relative;
background: white;
padding-top: 5px;
padding-bottom: 7px;
padding-left: 7px;
padding-right: 7px;
border-radius: 6px;
border: 3px solid #999;
font-size: 12px;
margin-bottom: 7px;
margin-right: 4px;
margin-left: 11px;
}
.userTextDivOp::before {
left: -18px !important;
right: 0px !important;
content: '';
position: absolute;
visibility: visible;
top: -3px;
border: 14px solid transparent;
border-top: 6px solid #999;
}
.userTextDivOp::after {
left: -6px;
right: 0px !important;
content: '';
position: absolute;
visibility: visible;
top: 0px;
border: 9px solid transparent;
border-top: 4px solid white;
clear: both;
}
.userTextDivOp .message {
word-break: break-all;
font-size: 12px;
}
.userTextDivOp .username {
position: relative;
display: block;
font-weight: bold;
font-size: 12px;
color: #8e0035;
}
<div class="userTextDiv">
<div class="username">user</div>
<span class="message">helphelphelphelphelphelphelphehelphelphelphelphelphelplphelphelphelphelphelphelphelphelphelphelphelphelp</span>
</div>
<div class="userTextDivOp">
<div class="username">customer</div>
<span class="message">click on oky button</span>
</div>
<div class="userTextDiv">
<div class="username">user</div>
<span class="message">click on oky button</span>
</div>
<div class="userTextDivOp">
<div class="username">customer</div>
<span class="message">helphelphelphelphelphelphelphehelphelphelphelphelphelplphelphelphelphelphelphelphelphelphelphelphelphelp</span>
</div>

you just need to wrap the message divs in a new div with a width:98%.
so that new message comes after the first one.
Thanks
.message-block{
width:98%;
height:auto;
overflow:hidden;
position:relative;
padding:0px 10px;
}
.userTextDiv {
position: relative;
background: white;
padding-bottom: 7px;
padding-left: 7px;
padding-right: 7px;
border-radius: 6px;
border: 3px solid #999;
border-top:2px solid #999;
float: right;
margin-bottom: 7px;
font-size: 12px;
text-align: right;
padding-top: 5px;
margin-right: 4px;
margin-left: 4px;
clear: right;
}
.userTextDiv::before {
content: '';
position: absolute;
visibility: visible;
top: -2px;
right: -10px;
border: 9px solid transparent;
border-top: 11px solid #999;
}
.userTextDiv::after {
content: '';
position: absolute;
visibility: visible;
top: 0.01em;
right: -6px;
border: 9px solid transparent;
border-top: 10px solid white;
clear: both;
}
.userTextDiv img {
display: block;
height: auto;
max-width: 100%;
}
.userTextDiv .username {
position: relative;
display: block;
font-weight: bold;
font-size: 12px;
color: #8e0035;
}
.userTextDiv .message {
word-break: break-all;
font-size: 12px;
}
.userTextDivOp {
text-align: left;
float: left;
clear: left;
position: relative;
background: white;
padding-top: 5px;
padding-bottom: 7px;
padding-left: 7px;
padding-right: 7px;
border-radius: 6px;
border: 3px solid #999;
font-size: 12px;
margin-bottom: 7px;
margin-right: 4px;
margin-left: 11px;
}
.userTextDivOp::before {
left: -14px !important;
right: 0px !important;
content: '';
position: absolute;
visibility: visible;
top: -3px;
border: 11px solid transparent;
border-top: 10px solid #999;
}
.userTextDivOp::after {
left: -9px;
right: 0px !important;
content: '';
position: absolute;
visibility: visible;
top: -0.09em;
border: 10px solid transparent;
border-top: 9px solid white;
clear: both;
}
.userTextDivOp .message {
word-break: break-all;
font-size: 12px;
}
.userTextDivOp .username {
position: relative;
display: block;
font-weight: bold;
font-size: 12px;
color: #8e0035;
}
<div class="message-block">
<div class="userTextDiv">
<div class="username">user</div>
<span class="message">helphelphelphelphelphelphelphehelphelphelphelphelphelplphelphelphelphelphelphelphelphelphelphelphelphelp</span>
</div>
</div>
<div class="message-block">
<div class="userTextDivOp">
<div class="username">customer</div>
<span class="message">click on oky button</span>
</div>
</div>
<div class="message-block">
<div class="userTextDiv">
<div class="username">user</div>
<span class="message">click on oky button</span>
</div>
</div>
<div class="message-block">
<div class="userTextDivOp">
<div class="username">customer</div>
<span class="message">helphelphelphelphelphelphelphehelphelphelphelphelphelplphelphelphelphelphelphelphelphelphelphelphelphelp</span>
</div>
</div>

A simple solution for you is to set clear: both; instead of clear: right; in the CSS rules of .userTextDiv and of .userTextDivOp.
To solve the corner problem, just c/p the CSS of .userTextDiv:before and after to replace the CSS of .userTextDivOp:before and after and replace right rules by left.
Hope it helps.
.userTextDiv {
position: relative;
background: white;
padding-bottom: 7px;
padding-left: 7px;
padding-right: 7px;
border-radius: 6px;
border: 3px solid #999;
float: right;
margin-bottom: 7px;
font-size: 12px;
text-align: right;
padding-top: 5px;
margin-right: 4px;
margin-left: 4px;
clear: both;
}
.userTextDiv::before {
content: '';
position: absolute;
visibility: visible;
top: -3px;
right: -11px;
border: 9px solid transparent;
border-top: 11px solid #999;
}
.userTextDiv::after {
content: '';
position: absolute;
visibility: visible;
top: 0px;
right: -6px;
border: 9px solid transparent;
border-top: 8px solid white;
clear: both;
}
.userTextDiv img {
display: block;
height: auto;
max-width: 100%;
}
.userTextDiv .username {
position: relative;
display: block;
font-weight: bold;
font-size: 12px;
color: #8e0035;
}
.userTextDiv .message {
word-break: break-all;
font-size: 12px;
}
.userTextDivOp {
text-align: left;
float: left;
clear: left;
position: relative;
background: white;
padding-top: 5px;
padding-bottom: 7px;
padding-left: 7px;
padding-right: 7px;
border-radius: 6px;
border: 3px solid #999;
font-size: 12px;
margin-bottom: 7px;
margin-right: 4px;
margin-left: 11px;
clear: both;
}
.userTextDivOp::before {
content: '';
position: absolute;
visibility: visible;
top: -3px;
left: -11px;
border: 9px solid transparent;
border-top: 11px solid #999;
}
.userTextDivOp::after {
content: '';
position: absolute;
visibility: visible;
top: 0px;
left: -6px;
border: 9px solid transparent;
border-top: 8px solid white;
clear: both;
}
.userTextDivOp .message {
word-break: break-all;
font-size: 12px;
}
.userTextDivOp .username {
position: relative;
display: block;
font-weight: bold;
font-size: 12px;
color: #8e0035;
}
<div class="userTextDiv">
<div class="username">user</div>
<span class="message">helphelphelphelphelphelphelphehelphelphelphelphelphelplphelphelphelphelphelphelphelphelphelphelphelphelp</span>
</div>
<div class="userTextDivOp">
<div class="username">customer</div>
<span class="message">click on oky button</span>
</div>
<div class="userTextDiv">
<div class="username">user</div>
<span class="message">click on oky button</span>
</div>
<div class="userTextDivOp">
<div class="username">customer</div>
<span class="message">helphelphelphelphelphelphelphehelphelphelphelphelphelplphelphelphelphelphelphelphelphelphelphelphelphelp</span>
</div>

Related

How do I make text overlap a shape in HTML/CSS?

Here, I'm making a food pyramid that has interactive buttons that allow you to add and take away the amount your of food your eating in each section of the pyramid. But, I'm not sure how to make the counter for each sector (the first triangle and then each trapezoid) overlap the circle its meant to be on. For example in the first sector (the triangle) there meant to be a circle in the middle of it that contains the counter on top of it and then a plus sign on the right, and a minus sign on the left.
.triangle {
border-bottom: 150px solid #FF6347;
border-left: 100px solid transparent;
border-right: 100px solid transparent;
height: 0;
width: 0;
margin-left: auto;
margin-right: auto;
white-space: nowrap;
display: block;
}
.trapezoid {
border-bottom: 100px solid #f58c57;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
height: 0;
width: 220px;
margin-left: auto;
margin-right: auto;
padding-bottom: 20px;
}
.trapezoid1 {
border-bottom: 100px solid #fff894;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
height: 0;
width: 360px;
margin-left: auto;
margin-right: auto;
padding-bottom: 20px;
}
.trapezoid2 {
border-bottom: 100px solid #83ccde;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
height: 0;
width: 480px;
margin-left: auto;
margin-right: auto;
}
.trapezoid3 {
border-bottom: 100px solid #a87d5c;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
height: 0;
width: 600px;
margin-left: auto;
margin-right: auto;
}
.trapezoid4 {
border-bottom: 100px solid #9effa6;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
height: 0;
width: 720px;
margin-left: auto;
margin-right: auto;
}
.circle1{
height: 45px;
width: 45px;
background-color: #ffffff;
border-radius: 50%;
display: inline-block;
margin-top: 100px;
margin-left: -22px;
margin-right: auto;
opacity: 0.7;
}
.circle2{
height: 50px;
width: 50px;
background-color: #ffffff;
border-radius: 50%;
display: inline-block;
margin-top: 45px;
margin-left: 87px;
margin-right: auto;
opacity: 0.7;
}
.circle3{
height: 50px;
width: 50px;
background-color: #ffffff;
border-radius: 50%;
display: inline-block;
margin-top: 45px;
margin-left: 158px;
margin-right: auto;
opacity: 0.7;
}
.circle4{
height: 50px;
width: 50px;
background-color: #ffffff;
border-radius: 50%;
display: inline-block;
margin-top: 25px;
margin-left: 219px;
margin-right: auto;
opacity: 0.7;
}
.circle5{
height: 50px;
width: 50px;
background-color: #ffffff;
border-radius: 50%;
display: inline-block;
margin-top: 25px;
margin-left: 279px;
margin-right: auto;
opacity: 0.7;
}
.circle6{
height: 50px;
width: 50px;
background-color: #ffffff;
border-radius: 50%;
display: inline-block;
margin-top: 25px;
margin-left: 339px;
margin-right: auto;
opacity: 0.7;
}
.button1 {
background-color: white;
border: none;
padding: 20px;
height: 5px;
width: 5px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: 0px;
top: -18px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button2{
background-color: white;
border: none;
padding: 20px;
height: 5px;
display: none;
width: 5px;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: -147px;
top: -18px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button3 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: 3px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button4 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: 30px;
top: -73px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button5 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: 5px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button6 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: -168px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button7 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: 5px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button8 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: -167px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button9 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: 6px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button10 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: -168px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button11 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: 6px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.button12 {
background-color: white;
border: none;
padding: 20px;
height: 10px;
width: 10px;
display: none;
margin-left: 0px;
cursor: pointer;
border-radius: 50%;
position: relative;
left: -169px;
top: -23px;
opacity: 0.7;
text-align: center;
text-decoration: none;
line-height: 5px;
}
.piece:hover .button1, .piece:hover .button2, .piece:hover .button3, .piece:hover .button4, .piece:hover .button5, .piece:hover .button6, .piece:hover .button7, .piece:hover .button8, .piece:hover .button9, .piece:hover .button10, .piece:hover .button11, .piece:hover .button12{
display: inline-block;
opacity: 0.7;
}
.text1{
text-align: center;
line-height: 0px;
font-family: "helvetica",serif;
font-size: 20px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="assignment01.css">
</head>
<body>
<h1 style = "font-family: helvetica"><center>Figure 1</center></h1>
<script type="text/javascript">
var clicks = 0;
function onClick() {
clicks += 1;
document.getElementById("clicks").innerHTML = clicks;
}
function onClickm() {
clicks -= 1;
document.getElementById("clicks").innerHTML = clicks;
}
</script>
<p class= "text1" id="clicks">0</p>
<div class="triangle piece">
<div class="circle1 "></div>
<div class="button1 " onClick="onClick()"><span>+</span></div>
<div class="button2" onClick="onClickm()"><span>-</span></div>
</div>
<div class="trapezoid piece">
<div class="circle2 "></div>
<div class="button3"><span>+</span></div>
<div class="button4"><span>-</span></div>
</div>
<div class="trapezoid1 piece">
<div class="circle3 "></div>
<div class="button5"><span>+</span></div>
<div class="button6"><span>-</span></div>
</div>
<div class="trapezoid2 piece">
<div class="circle4 "></div>
<div class="button7"><span>+</span></div>
<div class="button8"><span>-</span></div>
</div>
<div class="trapezoid3 piece">
<div class="circle5 "></div>
<div class="button9"><span>+</span></div>
<div class="button10"><span>-</span></div>
</div>
<div class="trapezoid4 piece">
<div class="circle6 "></div>
<div class="button11"><span>+</span></div>
<div class="button12"><span>-</span></div>
</div>
<h2 style = "font-family: helvetica"><center>My Food Pyramid</center></h2>
<label style = "font-family: helvetica" for="name"><center>Please Enter The Date:</center></label>
<center><input type="text" id="name" name="name" required maxlength="9" size="10"></center>
</body>
</html>
Why not place the counter directly in the circle in the HTML?
<div class="triangle piece">
<div class="circle1 "><p class= "text1" id="clicks">0</p></div>
<div class="button1 " onClick="onClick()"><span>+</span></div>
<div class="button2" onClick="onClickm()"><span>-</span></div>
</div>
Then you can use the .text1 css to position it exactly in the center.
.circle1{
height: 45px;
width: 45px;
background-color: #ffffff;
border-radius: 50%;
display: inline-block;
margin-top: 100px;
margin-left: -22px;
margin-right: auto;
opacity: 0.7;
position: relative;
}
.text1{
text-align: center;
line-height: 0px;
font-family: "helvetica",serif;
font-size: 20px;
position: absolute;
left: 18px;
top: 5px;
}
Because the counter is within the circle and the circle has position:relative the text will be positioned absolute with regards to the circle it's in.

how to have opposite speech bubble in css and html with arrow

I am trying to create a speech bubble with an arrow on the left and right side. Something like below
I have used the below CSS to achieve the same :
.speech-wrapper{
padding: 30px 40px;
}
.chatbox {
padding: 5px;
margin-left: 5px;
margin-right: 5px;
margin-top:3px;
background: #c7edfc;
color: #000;
position: relative;
border-radius: 4px;
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
}
.chatbox_other{
padding: 5px;
margin-left: 5px;
margin-right: 5px;
margin-top:3px;
background: #D3D3D3;
color: #000;
position: relative;
border-radius: 4px;
overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;
}
.name_other{
font-weight: 600;
position: absolute;
font-size: 12px;
margin: 0 0 4px;
color: #3498db;
bottom: 8px;
right: 10px;
}
.timestamp_other{
font-size: 11px;
position: absolute;
text-align: left;
bottom: 0px;
left: 10px;
text-transform: uppercase; color: #999
}
.timestamp{
font-size: 11px;
position: absolute;
bottom: 8px;
right: 10px;
text-transform: uppercase; color: #999
}
/* speech bubble 13 */
.name{
font-weight: 600;
font-size: 12px;
margin: 0 0 4px;
color: #3498db;
}
.bubble-arrow {
position: absolute;
width: 0;
bottom:42px;
left: -16px;
height: 0;
&.alt{
right: -2px;
bottom: 40px;
left: auto;
}
}
.bubble-arrow:after {
content: "";
position: absolute;
border: 0 solid transparent;
border-top: 9px solid #c7edfc;
border-radius: 0 20px 0;
width: 15px;
height: 30px;
transform: rotate(145deg);
}
.bubble-arrow.alt:after {
transform: rotate(45deg) scaleY(-1);
}
But for me, the arrow is missing always it always comes with a box.
I am a beginner to HTML and CSS any help on this will be appreciated.
Am I doing anything wrong to draw the rectangle?
EDIT:
I can see the chat bubble on chrome and all recent browsers but when I try using the very old browsers the below statement does not decode correctly. So the chat triangle was not in the appropriate position.
transform: rotate(145deg);
}
.bubble-arrow.alt:after {
transform: rotate(45deg) scaleY(-1);
}
HTML CODE:
<div class="speech-wrapper"><div class="chatbox"><div class="txt"><p class="name">TestUser1</p>Hi<span class="timestamp">10:20 pm</span></div><div class="bubble-arrow alt"></div></div>
Is there anything else can I use apart from the transform
Try this,
<!doctype html>
<html>
<head>
<title>Chat Bubbles Demo</title>
<style type="text/css">
.chat-box
{
width: 300px;
}
.header
{
padding: 10px;
color: white;
font-size: 14px;
font-weight: bold;
background-color: #6d84b4;
}
.messages
{
padding: 10px;
height: 200px;
background-color: green;
background-color: rgb(237, 239, 244);
border-width: 1px;
border-color: black;
border-style: solid;
overflow-y: scroll;
}
.messages ul
{
padding: 0px;
list-style-type: none;
}
.messages ul li
{
height: auto;
margin-bottom: 10px;
clear: both;
padding-left: 10px;
padding-right: 10px;
}
.messages ul li span
{
display: inline-block;
max-width: 200px;
background-color: white;
padding: 5px;
border-radius: 4px;
position: relative;
border-width: 1px;
border-style: solid;
border-color: grey;
}
.messages ul li span.left
{
float: left;
}
.messages ul li span.left:after
{
content: "";
display: inline-block;
position: absolute;
left: -8.5px;
top: 7px;
height: 0px;
width: 0px;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-right: 8px solid white;
}
.messages ul li span.left:before
{
content: "";
display: inline-block;
position: absolute;
left: -9px;
top: 7px;
height: 0px;
width: 0px;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-right: 8px solid black;
}
.messages ul li span.right:after
{
content: "";
display: inline-block;
position: absolute;
right: -8px;
top: 6px;
height: 0px;
width: 0px;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-left: 8px solid #dbedfe;
}
.messages ul li span.right:before
{
content: "";
display: inline-block;
position: absolute;
right: -9px;
top: 6px;
height: 0px;
width: 0px;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-left: 8px solid black;
}
.messages ul li span.right
{
float: right;
background-color: #dbedfe;
}
.clear
{
clear: both;
}
.input-box
{
background-color: white;
height: 50px;
padding: 0px;
}
.input-box textarea
{
padding: 0px;
width: 278px;
height: 100%;
display: inline-block;
outline: 0px;
border-width: 0px;
resize: none;
border-width: 1px;
border-color: black;
border-style: solid;
font-size: 12px;
padding: 10px;
border-top-width: 0px;
}
</style>
</head>
<body>
<div class="chat-box">
<div class="header">
Narayan Prusty
</div>
<div id="messages" class="messages">
<ul>
<li>
<span class="left">Hello</span>
<div class="clear"></div>
</li>
<li>
<span class="left">Are you there?</span>
<div class="clear"></div>
</li>
<li>
<span class="right">Yes I am here</span>
<div class="clear"></div>
</li>
<li>
<span class="left">Thanks for accepting my friend request</span>
<div class="clear"></div>
</li>
<li>
<span class="right">You Welcome</span>
<div class="clear"></div>
</li>
<li>
<span class="left">Bye</span>
<div class="clear"></div>
</li>
</ul>
<div class="clear"></div>
</div>
<div class="input-box">
<textarea placeholder="Enter message"></textarea>
</div>
</div>
</body>
</html>

margin-top is not working

I'm trying to implement a popup at the bottom right corner of my web in WordPress.
The popup is working properly, but I have 2 lines of text, a message and a button. Everything was okay since I wanted to put a margin-top in the button because the button was covering the text.
Here you can see the HTML code and the CSS.
#corner-slider {
position: fixed;
z-index: 10000;
overflow: hidden;
border-radius: 15px;
color: white;
padding: 10px;
margin-bottom: 60px;
height: 120px;
width: 369px;
border: 1px solid #2d93f1;
background: #2d93f1;
}
#corner-slider.hidden {
display: none;
}
#corner-slider .close {
position: absolute;
cursor: pointer;
font-size: 16px;
display: inline-block;
z-index: 1002;
right: 24px;
top: 10px;
}
.popup-button {
padding: 8px 30px;
background-color: #ffffff;
border-color: #ffffff;
border-radius: 45px;
margin-top: 240px;
}
<div id="corner-slider">
Do you want to stay here?
<br />
<a target="_blank" href="#" class="popup-button">Click me!</a>
</div>
So, why is margin-top not working? What can I do?
Thanks.
The anchor element <a> is an inline element. Change its display type to inline-block or block:
#corner-slider {
position: fixed;
z-index: 10000;
overflow: hidden;
border-radius: 15px;
color: white;
padding: 10px;
margin-bottom: 60px;
height: 120px;
width: 369px;
border: 1px solid #2d93f1;
background: #2d93f1;
}
#corner-slider.hidden {
display: none;
}
#corner-slider .close {
position: absolute;
cursor: pointer;
font-size: 16px;
display: inline-block;
z-index: 1002;
right: 24px;
top: 10px;
}
.popup-button {
padding: 8px 30px;
background-color: #ffffff;
border-color: #ffffff;
border-radius: 45px;
display: inline-block;
margin-top: 1em;
}
<div id="corner-slider">
Do you want to stay here?
<br />
<a target="_blank" href="#" class="popup-button">Click me!</a>
</div>
button is not stable, just add disply:inline-block or float:left
#corner-slider {
position: fixed;
z-index: 10000;
overflow: hidden;
border-radius: 15px;
color: white;
padding: 10px;
margin-bottom: 60px;
height: 120px;
width: 369px;
border: 1px solid #2d93f1;
background: #2d93f1;
}
#corner-slider.hidden {
display: none;
}
#corner-slider .close {
position: absolute;
cursor: pointer;
font-size: 16px;
display: inline-block;
z-index: 1002;
right: 24px;
top: 10px;
}
.popup-button {
padding: 8px 30px;
background-color: #ffffff;
border-color: #ffffff;
border-radius: 45px;
margin-top: 10px;
display: inline-block; /* newly added */
}
<div id="corner-slider">
Do you want to stay here?
<br />
<a target="_blank" href="#" class="popup-button">Click me!</a>
</div>
i made some changes in your code just have a look in the below code, just place the text in the div and add a css of margin-bottom:15px;
<style>
#corner-slider {
position:fixed;
z-index:10000;
overflow:hidden;
border-radius: 15px;
color: white;
padding: 10px;
margin-bottom: 60px;
height: 120px;
width:369px;
border:1px solid #2d93f1;
background:#2d93f1;
}
#corner-slider.hidden{
display:none;
}
#corner-slider .close{
position:absolute;
cursor:pointer;
font-size:16px;
display:inline-block;
z-index:1002;
right:24px;
top:10px;
}
.popup-button {
padding: 8px 30px;
background-color: #ffffff;
border-color: #ffffff;
border-radius: 45px;
margin-top: 240px;
}
/*--------------- new css ----------*/
.small-area
{
margin-bottom: 15px;
}
</style>
<div id="corner-slider">
<div class="small-area">Do you want to stay here?</div>
<a target="_blank" href="#" class="popup-button">Click me!</a>
</div>

How do I get this button layout?

I'm trying to get this layout.
<blockquote class="imgur-embed-pub" lang="en" data-id="a/kCjW9"></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
Here's the code I have. I can't seem to get z-index to work so that I could bring black border on top of the background.
<blockquote class="imgur-embed-pub" lang="en" data-id="a/6a7Ev"></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
.btn {
border-radius: 0px!important;
font-family: $font-roboto!important;
font-size: 1.125rem!important;
text-shadow: none!important;
box-shadow: none!important;
&.fountain-blue {
background-color: $color-fountain-blue;
color: #fff;
margin-left:5px;
margin-top: 5px;
margin-right: -10px;
}
}
.btn-border {
border: 2px solid #000;
display: inline-block;
height: 40px;
z-index: 9999!important;
}
<div class="btn-border mt-4">
learn more about us
</div>
There are a lot of ways to do this but simple method is to use pseudo-elements. check out the snippet.
CODEPEN (SASS version)
#import url("https://fonts.googleapis.com/css?family=Roboto");
.btn {
border-radius: 0px;
font-size: 1.125rem;
text-shadow: none;
box-shadow: none;
display: block;
width: calc(100% - 25px);
text-decoration: none;
font-family: 'Roboto', sans-serif;
text-align: center;
}
.btn.fountain-blue {
background-color: #65becf;
color: #fff;
margin-left: 5px;
margin-top: 5px;
padding-top: 10px;
padding-bottom: 15px;
padding-left: 15px;
padding-right: 15px;
position: relative;
}
.btn-border {
display: inline-block;
height: 40px;
z-index: 9999;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.btn-border:after {
content: '';
border: 2px solid #000;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
<div class="btn-border mt-4">
READ MORE
</div>
You should do it something like this, but than with your own colors and sizes.
.btn {
display: inline-block;
border: 1px solid black;
position: relative;
padding: 10px 20px;
margin: 20px;
color: #fff;
}
.btn:before {
background-color: blue;
border-color: green;
border-style: solid;
border-width: 10px 5px 5px 10px;
z-index: -1;
position: absolute;
height: 100%;
width: 100%;
top: -5px;
left: -5px;
content: "";
}
<a class="btn">Read more</a>
As a possible solution.
* {
box-sizing: border-box;
}
body {
margin: 2em;
}
.btn {
background-color: darkblue;
color: white;
border: .2em solid white;
height: 2.5em;
width: 7em;
position: relative;
cursor: pointer;
}
.btn:before {
content: " ";
width: 9em;
height: 4em;
background-color: lightblue;
position: absolute;
top: -1em;
left: -1em;
z-index: -1;
}
.btn:after {
content: " ";
position: absolute;
background-color: transparent;
border: thin solid black;
height: 2em;
width: 6.5em;
top: -.5em;
left: -.5em;
}
<button class="btn">Click me</button>

Css for tool tip in rope down menu

I want to make a tool tip for drop down but am having problem in the arrow please can some one position it the way i want it thank you
Here is what i get
I want it to look like this
Here is my CSS code
<style>
#wrapper-err {
position: absolute;
display: inline-block;
display: flex;
align-items: center;
justify-content: center;
z-index: 2222;
width:210px;
height:90px;
margin-top:2em;
margin-left:2em;
}
.err-tip {
background-color: #D03B3E;
color:#fff;
padding:0.5em;
}
.err-tip::before {
content: "";
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-top: 18px solid #D03B3E;
position: absolute;
top: -18px;
left: 50%;
margin-left: -4px;
display: block;
}
.err-tip div{
margin: 0px;
border: 0px none;
font: inherit;
vertical-align: baseline;
outline: medium none;
}
.err-close{
float: right;
position: absolute;
top: 1px;
right: 1px;
cursor: pointer;
border: 1px dotted;
margin: 0.2em;
}
.err-tip p{
margin-right: 0.4em;
margin-top: 0.4em;
margin-bottom: 0.4em;
}
</style>
HTML
<div class="err-tip" id="wrapper-err">
<span class="err-close">X</span>
<p>hfdbmxvncbv jkjfvkbcjkjzcjxvbckjkjzckxvjbc.</p>
</div>
just change the arrow border like this:
.err-tip::before {
content: "";
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-bottom: 18px solid #D03B3E; /* changed from top to bottom */
position: absolute;
top: -18px;
right: 25px; /* change the horizontal position */
margin-left: -4px;
display: block;
}
Here is a snippet:
#wrapper-err {
position: absolute;
display: inline-block;
display: flex;
align-items: center;
justify-content: center;
z-index: 2222;
width:210px;
height:90px;
margin-top:2em;
margin-left:2em;
}
.err-tip {
background-color: #D03B3E;
color:#fff;
padding:0.5em;
}
.err-tip::before {
content: "";
width: 0;
height: 0;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
border-bottom: 18px solid #D03B3E;
position: absolute;
top: -18px;
right: 25px;
margin-left: -4px;
display: block;
}
.err-tip div{
margin: 0px;
border: 0px none;
font: inherit;
vertical-align: baseline;
outline: medium none;
}
.err-close{
float: right;
position: absolute;
top: 1px;
right: 1px;
cursor: pointer;
border: 1px dotted;
margin: 0.2em;
}
.err-tip p{
margin-right: 0.4em;
margin-top: 0.4em;
margin-bottom: 0.4em;
}
<div class="err-tip" id="wrapper-err">
<span class="err-close">X</span>
<p>the text.</p>
</div>