How can we apply 1px borders to these speech bubbles?
This similar SO post did not work here, as we use a different approach to generate the speech bubbles
.chat-messages {
width: calc(100%);
padding-bottom: 5px;
background-color: #f3f3f4;
}
.sb-time {
font-size: 10pt;
font-weight: 400;
margin: 7px -5px 0px 10px;
float: right;
}
.sb {
font-size: 13pt;
font-weight: 500;
border-radius: 6px;
display: block;
padding: 10px 15px 5px 15px;
position: relative;
vertical-align: top;
clear: both;
}
.sb::before {
content: "\00a0";
display: block;
height: 15px;
position: absolute;
top: 10px;
-moz-transform: rotate(30deg) skew(-35deg);
-ms-transform: rotate(30deg) skew(-35deg);
-o-transform: rotate(30deg) skew(-35deg);
-webkit-transform: rotate(30deg) skew(-35deg);
transform: rotate(30deg) skew(-35deg);
width: 15px;
}
.sb-0 {
background-color: #ffffff;
float: left;
margin: 5px 17% 5px 20px;
}
.sb-0::before {
background-color: #ffffff;
left: -8px;
}
.sb-1 {
background-color: #EEFFDD;
float: right;
margin: 5px 20px 5px 17%;
}
.sb-1::before {
background-color: #EEFFDD;
right: -8px;
}
<div class="chat-messages" style="max-height: 472px; overflow: hidden; width: auto; height: 472px;">
<div class="sb sb-text sb-0">Hi
<div class="sb-time">09:16</div>
</div>
<div class="sb sb-text sb-0">Fine. Thnks
<div class="sb-time">09:19</div>
</div>
<div class="sb sb-text sb-1">What subject u are talking about ?
<div class="sb-time">09:19</div>
</div>
</div>
Have a look at this Jsfiddle.
These are the changes I made:
.sb {
border: 1px solid #000;
}
.sb::before {
height: 12px;
top: 12px;
border-left: 1px solid #000;
border-bottom: 1px solid #000;
}
.sb-0 {
background-color: #ffffff;
float: left;
margin: 5px 17% 5px 20px;
}
.sb-0::before {
left: -9px;
}
EDIT
Updated Jsfiddle to contain the bubble on the right side also.
UPDATE
Prefixes for transform 2D are no longer needed, see CanIUse
.sb {
....
border: 1px solid red;
}
.sb-0::before {
....
border-left: 1px solid red;
border-bottom: 1px solid red;
transform: rotate(35deg) skew(-25deg) translate(-1px, 0);
width: 16px;
height: 14px;
}
.sb-1::before {
....
border-right: 1px solid red;
border-top: 1px solid red;
transform: rotate(35deg) skew(-25deg) translate(1px, 0);
width: 16px;
height: 14px;
}
SNIPPET
body {
background: #000;
}
.chat-messages {
width: calc(100%);
padding-bottom: 5px;
background-color: #666;
}
.sb-time {
font-size: 10pt;
font-weight: 400;
margin: 7px -5px 0px 10px;
float: right;
}
.sb {
font-size: 13pt;
font-weight: 500;
border-radius: 6px;
display: block;
padding: 10px 15px 5px 15px;
position: relative;
vertical-align: top;
clear: both;
border: 1px solid red;
}
.sb-0:before {
content: "\00a0";
display: block;
position: absolute;
top: 10px;
transform: rotate(25deg) skew(-35deg) translate(-1px, 0);
width: 16px;
height: 14px;
border-left: 1px solid red;
border-bottom: 1px solid red;
}
.sb-1:before {
content: "\00a0";
display: block;
position: absolute;
top: 10px;
transform: rotate(25deg) skew(-35deg) translate(1px, 0);
width: 16px;
height: 14px;
border-right: 1px solid red;
border-top: 1px solid red;
}
.sb-0 {
background-color: #ffffff;
float: left;
margin: 5px 17% 5px 20px;
}
.sb-0::before {
background-color: #ffffff;
left: -8px;
}
.sb-1 {
background-color: #EEFFDD;
float: right;
margin: 5px 20px 5px 17%;
}
.sb-1::before {
background-color: #EEFFDD;
right: -8px;
}
<div class="chat-messages" style="max-height: 472px; overflow: hidden; width: auto; height: 472px;">
<div class="sb sb-text sb-0">Hi
<div class="sb-time">09:16</div>
</div>
<div class="sb sb-text sb-0">Fine. Thnks
<div class="sb-time">09:19</div>
</div>
<div class="sb sb-text sb-1">What subject u are talking about ?
<div class="sb-time">09:19</div>
</div>
</div>
Related
I'm trying to draw a circle with tick/checkmark inside it using pure css3
.success-checkmark {
content: '✔';
position: absolute;
left:0; top: 2px;
width: 17px; height: 17px;
border: 1px solid #aaa;
background: #f8f8f8;
border-radius: 50%;
box-shadow: inset 0 1px 3px rgba(0,0,0,.3)
}
How can i achieve i have tried with the above code?
You can use content: '✔'; only on pseudo elements, so try using the following selector:
.success-checkmark:after {
content: '✔';
position: absolute;
left:0; top: 2px;
width: 20px;
height: 20px;
text-align: center;
border: 1px solid #aaa;
background: #f8f8f8;
border-radius: 50%;
box-shadow: inset 0 1px 3px rgba(0,0,0,.3)
}
<div class="success-checkmark"></div>
.wrapper {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.circle {
position: relative;
background: #00B01D;
border-radius: 100%;
height: 120px;
width: 120px;
}
.checkMark {
position: absolute;
transform: rotate(50deg) translate(-50%, -50%);
left: 27%;
top: 43%;
height: 60px;
width: 25px;
border-bottom: 5px solid #fff;
border-right: 5px solid #fff;
}
<div class="wrapper">
<div class="circle">
<div class="checkMark"></div>
</div>
</div>
I found a template online to which I made modifications. Kindly check if this works for you.
:root {
--borderWidth: 7px;
--height: 25px;
--width: 12px;
--borderColor: white;
}
body {
padding: 20px;
text-align: center;
}
.check {
display: inline-block;
transform: rotate(45deg);
height: var(--height);
width: var(--width);
border-bottom: var(--borderWidth) solid var(--borderColor);
border-right: var(--borderWidth) solid var(--borderColor);
}
.behind {
border-radius: 50%;
width: 40px;
height: 40px;
background: black;
}
<div class="behind">
<div class="check">
</div>
</div>
css
.success-checkmark:after {
content: '✔';
position: absolute;
text-align: center;
line-height:20px;
}
vertical adjustment
line-height:20px;<--- adjust vertical alignment
.success-checkmark:after {
content: '✔';
position: absolute;
text-align: center;
line-height:20px;
width: 90px;
height: 90px;
border: 1px solid #aaa;
background: #f8f8f8;
border-radius: 50%;
box-shadow: inset 0 1px 3px rgba(0,0,0,.3)
}
<div class="success-checkmark"></div>
This has been really frustrating. I'm trying to add a dropdown tooltip at the bottom of my profile avatar. Unfortunately that does not seem to work properly. The tooltip seems to be partly hidden. How can i keep the specific design of the tooltip and make it display directly at the bottom of the icon with the arrow pointing in the middle of the icon?
body {
background-color: #36a4b0;
}
#shell-header {
display: flex;
height: 46px;
overflow: hidden;
z-index: 3;
opacity: 1;
white-space: nowrap;
}
.logo-wrapper {
padding-left: 56px;
}
#media (max-width: 480px) {
.logo-wrapper {
padding-left: 1rem;
}
}
.title-wrapper {
left: 0;
right: 0;
text-align: right;
flex-grow: 1;
}
.avatar-wrapper {
padding-right: 56px;
position: relative;
}
#media (max-width: 480px) {
.avatar-wrapper {
padding-right: 1rem;
}
}
.logo {
height: 30px;
line-height: 40px;
max-width: 96px;
margin-top: 0.35rem;
}
.log-shellHeaderTitle {
font-size: 20px;
line-height: 36px;
color: #fff;
text-overflow: ellipsis;
text-align: center;
display: block;
white-space: nowrap;
overflow: hidden;
font-weight: inherit;
margin-left: 0px;
margin-top: 0px;
margin-bottom: 0px;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}
.log-langButton {
padding-right: 40px;
}
#media only screen and (max-width: 480px) {
.log-langButton {
padding-right: 10px;
}
}
#log-LangButtSwitch {
background: transparent;
cursor: pointer;
display: block;
position: relative;
float: left;
width: 40px;
padding: 2px;
margin-top: 0.25rem;
border: 2px solid #fff;
border-radius: 28px;
}
.log-switchHandle {
display: block;
background: #fff;
height: 20px;
width: 20px;
z-index: 9999;
border-radius: 20px;
}
.log-switchLabels {
position: absolute;
top: 5px;
z-index: -1;
width: 100%;
font-family: Helvetica, sans-serif;
font-weight: bold;
color: #fff;
text-transform: uppercase;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}
.log-switchLabels:before {
content: "EN";
position: absolute;
left: 21px;
font-size: 12px;
}
.log-switchLabels:after {
content: "DE";
position: absolute;
right: 26px;
font-size: 12px;
}
.fa-user-o:before {
font-size: 1.375rem;
color: #fff;
}
.avatar {
text-align: center;
margin-top: 0.35rem;
width: 25px;
}
.log-popover {
visibility: visible;
z-index: 460;
display: block;
overflow: visible;
top: 121px;
left: 375.063px;
bottom: 10px;
transition: opacity 0.2s linear;
color: #333333;
min-width: 100px;
box-sizing: border-box;
outline: none;
max-width: 100%;
max-height: 84px;
min-height: 2rem;
overflow: hidden;
background: #ffffff;
border: none;
box-shadow: 0 0.625rem 1.875rem 0 rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
}
.log-popover a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.log-popover a:hover {
background-color: #f0f0f0;
}
.log-popover a:active,
.log-popover a:focus {
background: #e8eff6;
outline: 1px dotted #000000;
outline-offset: -2px;
}
.log-popover:after,
.log-popover:before {
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.log-popover:after {
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #fff;
border-width: 10px;
margin-left: -10px;
}
.log-popover:before {
border-color: rgba(51, 51, 51, 0);
border-bottom-color: #333333;
border-width: 11px;
margin-left: -11px;
}
.log-toolContainer {
position: absolute;
height: 100%;
width: 100%;
}
<div class="log-container">
<div id="shell-header">
<div class="logo-wrapper">
<img src="https://s-media-cache-ak0.pinimg.com/236x/f7/0a/f6/f70af6169bbe3f8346e64a25d54bafea.jpg" class="logo">
</div>
<div class="title-wrapper">
<div class="log-shellHeaderTitle">Dashboard</div>
</div>
<div class="log-langButton">
<div id="log-LangButtSwitch">
<span class="log-switchHandle"></span>
<span class="log-switchLabels"></span>
</div>
</div>
<div class="avatar-wrapper">
<img class="avatar" src="https://www.talentenportaalhellendoorn.nl/thumbnails/man.png">
<div class="log-toolContainer">
<div class="log-popover">
Profile
Log out
</div>
</div>
</div>
</div>
</div>
remove overflow: hidden; from #shell-header so the menu isn't cut off, then use positioning to put the container for the menu in the bottom/left of the parent, and use translateX() to offset it 50% of it's own width + 50% of the avatar width to center it under the icon.
body {
background-color: #36a4b0;
}
#shell-header {
display: flex;
height: 46px;
z-index: 3;
opacity: 1;
white-space: nowrap;
}
.logo-wrapper {
padding-left: 56px;
}
#media (max-width: 480px) {
.logo-wrapper {
padding-left: 1rem;
}
}
.title-wrapper {
left: 0;
right: 0;
text-align: right;
flex-grow: 1;
}
.avatar-wrapper {
padding-right: 56px;
position: relative;
}
#media (max-width: 480px) {
.avatar-wrapper {
padding-right: 1rem;
}
}
.logo {
height: 30px;
line-height: 40px;
max-width: 96px;
margin-top: 0.35rem;
}
.log-shellHeaderTitle {
font-size: 20px;
line-height: 36px;
color: #fff;
text-overflow: ellipsis;
text-align: center;
display: block;
white-space: nowrap;
overflow: hidden;
font-weight: inherit;
margin-left: 0px;
margin-top: 0px;
margin-bottom: 0px;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}
.log-langButton {
padding-right: 40px;
}
#media only screen and (max-width: 480px) {
.log-langButton {
padding-right: 10px;
}
}
#log-LangButtSwitch {
background: transparent;
cursor: pointer;
display: block;
position: relative;
float: left;
width: 40px;
padding: 2px;
margin-top: 0.25rem;
border: 2px solid #fff;
border-radius: 28px;
}
.log-switchHandle {
display: block;
background: #fff;
height: 20px;
width: 20px;
z-index: 9999;
border-radius: 20px;
}
.log-switchLabels {
position: absolute;
top: 5px;
z-index: -1;
width: 100%;
font-family: Helvetica, sans-serif;
font-weight: bold;
color: #fff;
text-transform: uppercase;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}
.log-switchLabels:before {
content: "EN";
position: absolute;
left: 21px;
font-size: 12px;
}
.log-switchLabels:after {
content: "DE";
position: absolute;
right: 26px;
font-size: 12px;
}
.fa-user-o:before {
font-size: 1.375rem;
color: #fff;
}
.avatar {
text-align: center;
margin-top: 0.35rem;
width: 25px;
}
.log-popover {
visibility: visible;
z-index: 460;
display: block;
overflow: visible;
top: 121px;
left: 375.063px;
bottom: 10px;
transition: opacity 0.2s linear;
color: #333333;
min-width: 100px;
box-sizing: border-box;
outline: none;
max-width: 100%;
max-height: 84px;
min-height: 2rem;
overflow: hidden;
background: #ffffff;
border: none;
box-shadow: 0 0.625rem 1.875rem 0 rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
}
.log-popover a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.log-popover a:hover {
background-color: #f0f0f0;
}
.log-popover a:active,
.log-popover a:focus {
background: #e8eff6;
outline: 1px dotted #000000;
outline-offset: -2px;
}
.log-popover:after,
.log-popover:before {
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.log-popover:after {
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #fff;
border-width: 10px;
margin-left: -10px;
}
.log-popover:before {
border-color: rgba(51, 51, 51, 0);
border-bottom-color: #333333;
border-width: 11px;
margin-left: -11px;
}
.log-toolContainer {
position: absolute;
height: 100%;
width: 100%;
top: 100%;
left: 0;
transform: translateX(calc(-50% + 12.5px));
}
<div class="log-container">
<div id="shell-header">
<div class="logo-wrapper">
<img src="https://s-media-cache-ak0.pinimg.com/236x/f7/0a/f6/f70af6169bbe3f8346e64a25d54bafea.jpg" class="logo">
</div>
<div class="title-wrapper">
<div class="log-shellHeaderTitle">Dashboard</div>
</div>
<div class="log-langButton">
<div id="log-LangButtSwitch">
<span class="log-switchHandle"></span>
<span class="log-switchLabels"></span>
</div>
</div>
<div class="avatar-wrapper">
<img class="avatar" src="https://www.talentenportaalhellendoorn.nl/thumbnails/man.png">
<div class="log-toolContainer">
<div class="log-popover">
Profile
Log out
</div>
</div>
</div>
</div>
</div>
Remove overflow hidden from #shell-header...
body {
background-color: #36a4b0;
}
#shell-header {
display: flex;
height: 46px;
overflow: visible;
z-index: 3;
opacity: 1;
white-space: nowrap;
}
.logo-wrapper {
padding-left: 56px;
}
#media (max-width: 480px) {
.logo-wrapper {
padding-left: 1rem;
}
}
.title-wrapper {
left: 0;
right: 0;
text-align: right;
flex-grow: 1;
}
.avatar-wrapper {
padding-right: 56px;
position: relative;
}
#media (max-width: 480px) {
.avatar-wrapper {
padding-right: 1rem;
}
}
.logo {
height: 30px;
line-height: 40px;
max-width: 96px;
margin-top: 0.35rem;
}
.log-shellHeaderTitle {
font-size: 20px;
line-height: 36px;
color: #fff;
text-overflow: ellipsis;
text-align: center;
display: block;
white-space: nowrap;
overflow: hidden;
font-weight: inherit;
margin-left: 0px;
margin-top: 0px;
margin-bottom: 0px;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}
.log-langButton {
padding-right: 40px;
}
#media only screen and (max-width: 480px) {
.log-langButton {
padding-right: 10px;
}
}
#log-LangButtSwitch {
background: transparent;
cursor: pointer;
display: block;
position: relative;
float: left;
width: 40px;
padding: 2px;
margin-top: 0.25rem;
border: 2px solid #fff;
border-radius: 28px;
}
.log-switchHandle {
display: block;
background: #fff;
height: 20px;
width: 20px;
z-index: 9999;
border-radius: 20px;
}
.log-switchLabels {
position: absolute;
top: 5px;
z-index: -1;
width: 100%;
font-family: Helvetica, sans-serif;
font-weight: bold;
color: #fff;
text-transform: uppercase;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
}
.log-switchLabels:before {
content: "EN";
position: absolute;
left: 21px;
font-size: 12px;
}
.log-switchLabels:after {
content: "DE";
position: absolute;
right: 26px;
font-size: 12px;
}
.fa-user-o:before {
font-size: 1.375rem;
color: #fff;
}
.avatar {
text-align: center;
margin-top: 0.35rem;
width: 25px;
}
.log-popover {
visibility: visible;
z-index: 460;
display: block;
overflow: visible;
top: 121px;
left: 375.063px;
bottom: 10px;
transition: opacity 0.2s linear;
color: #333333;
min-width: 100px;
box-sizing: border-box;
outline: none;
max-width: 100%;
max-height: 84px;
min-height: 2rem;
overflow: hidden;
background: #ffffff;
border: none;
box-shadow: 0 0.625rem 1.875rem 0 rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
}
.log-popover a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.log-popover a:hover {
background-color: #f0f0f0;
}
.log-popover a:active,
.log-popover a:focus {
background: #e8eff6;
outline: 1px dotted #000000;
outline-offset: -2px;
}
.log-popover:after,
.log-popover:before {
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.log-popover:after {
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #fff;
border-width: 10px;
margin-left: -10px;
}
.log-popover:before {
border-color: rgba(51, 51, 51, 0);
border-bottom-color: #333333;
border-width: 11px;
margin-left: -11px;
}
.log-toolContainer {
position: absolute;
height: 100%;
width: 100%;
}
<div class="log-container">
<div id="shell-header">
<div class="logo-wrapper">
<img src="https://s-media-cache-ak0.pinimg.com/236x/f7/0a/f6/f70af6169bbe3f8346e64a25d54bafea.jpg" class="logo">
</div>
<div class="title-wrapper">
<div class="log-shellHeaderTitle">Dashboard</div>
</div>
<div class="log-langButton">
<div id="log-LangButtSwitch">
<span class="log-switchHandle"></span>
<span class="log-switchLabels"></span>
</div>
</div>
<div class="avatar-wrapper">
<img class="avatar" src="https://www.talentenportaalhellendoorn.nl/thumbnails/man.png">
<div class="log-toolContainer">
<div class="log-popover">
Profile
Log out
</div>
</div>
</div>
</div>
</div>
I've been searching the Internet for a while and found nothing, so I'm turning to you guys.
I was wondering how you can do a button like this with CSS (On/Off button example):
I already tried something like this :
HTML :
<a class="button_tooltip" href="#">On</a>
<a class="button_tooltip" href="#">Off</a>
CSS:
a {
color: #76daff;
display: inline-block;
padding: 8px 16px;
position: relative;
text-decoration: none;
}
a {
color: #76daff;
}
a.button_tooltip {
background: #ccc none repeat scroll 0 0;
color: black;
}
a.button_tooltip::after {
border-top-color: #cccccc;
}
a.button_tooltip::after {
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #ccc;
content: "";
margin-left: -8px;
}
a.button_tooltip {
background: #cccccc none repeat scroll 0 0;
color: #000000;
}
a.button_tooltip::after {
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 8px solid #ccc;
content: "";
}
a.button_tooltip::after {
border-top-color: #cccccc;
}
But only gave me the square without the little triangle underneath.
This is easily possible with 2 elements and using a pseudo element to get the arrow bit underneath to show.
It doesn't take a great deal of HTML/CSS to complete and can easily be changed to work as an input or as an <a> tag. Whatever your requirements are.
$(document).ready(function() {
$('.btn').click(function() {
$('.btn').toggleClass('active');
});
});
.container {
width: 200px;
height: 100px;
}
.btn {
width: 100px;
height: 100px;
box-sizing: border-box;
border: 1px solid blue;
float: left;
cursor: pointer;
}
.active {
background: blue;
position: relative;
}
.active:before {
content: '';
position: absolute;
width: 50px;
height: 50px;
transform: rotate(45deg);
bottom: -10px;
left: 25px;
background: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="btn"></div>
<div class="btn active"></div>
</div>
$(document).ready(function() {
$('.toggle-btn button').click(function() {
$(this).parent('.toggle-btn').children('button').removeClass('active');
$(this).addClass('active');
});
});
.toggle-btn {
border: 1px solid #4c8cca;
display: inline-block;
line-height: 1;
width: 100px;
}
button {
line-height: 1;
float: left;
height: 30px;
background: none;
background-color: transparent;
border: none;
padding: 0;
position: relative;
outline: 0;
width: 50%;
cursor: pointer;
}
button:hover {
background-color: #EEE;
}
button.active {
background: #4c8cca;
background-color: #4c8cca;
color: #FFF;
}
button.active:after {
content: '';
position: absolute;
width: 10px;
height: 10px;
top: 25px;
transform: rotate(45deg);
background-color: #4c8cca;
left: 50%;
margin-left: -4px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="toggle-btn">
<button>Yes</button>
<button class="active">No</button>
</div>
Here you go:
http://jsfiddle.net/es_kaija/negzqemp/
<div class="switch off">
<div class="toggle"></div>
<span class="on">ON</span>
<span class="off">OFF</span>
</div>
<style>
.switch {
position: relative;
display: inline-block;
font-size: 1em;
font-weight: bold;
color: #ccc;
text-shadow: 0px 1px 1px rgba(255,255,255,0.8);
height: 18px;
padding: 6px 6px 5px 6px;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,0.2);
border-radius: 4px;
background: #ececec;
box-shadow: 0px 0px 4px rgba(0,0,0,0.1), inset 0px 1px 3px 0px rgba(0,0,0,0.1);
cursor: pointer;
}
.switch span { display: inline-block; width: 35px; }
.switch span.On { color: #33d2da; }
.switch .toggle {
position: absolute;
top: 1px;
width: 37px;
height: 25px;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,0.3);
border-radius: 4px;
background: #fff;
background: -moz-linear-gradient(top, #ececec 0%, #ffffff 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ececec), color-stop(100%,#ffffff));
background: -webkit-linear-gradient(top, #ececec 0%,#ffffff 100%);
background: -o-linear-gradient(top, #ececec 0%,#ffffff 100%);
background: -ms-linear-gradient(top, #ececec 0%,#ffffff 100%);
background: linear-gradient(top, #ececec 0%,#ffffff 100%);
box-shadow: inset 0px 1px 0px 0px rgba(255,255,255,0.5);
z-index: 999;
-webkit-transition: all 0.15s ease-in-out;
-moz-transition: all 0.15s ease-in-out;
-o-transition: all 0.15s ease-in-out;
-ms-transition: all 0.15s ease-in-out;
}
.switch.on .toggle { left: 2%; }
.switch.off .toggle { left: 54%; }
</style>
<script>
$(document).ready(function() {
// Switch toggle
$('.switch').click(function() {
$(this).toggleClass('on').toggleClass('off');
});
});
</script>
You can do that using css itself. Here is the example - https://jsfiddle.net/p653bpbe/
html
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
css
.onoffswitch {
position: relative; width: 90px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
border: 1px solid #2E8DEF; border-radius: 0px;
}
.onoffswitch-inner {
display: block; width: 200%; margin-left: -100%;
transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 26px;
font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
box-sizing: border-box;
border: 2px solid transparent;
background-clip: padding-box;
}
.onoffswitch-inner:before {
content: "";
padding-left: 10px;
background-color: #FFFFFF; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "";
padding-right: 10px;
background-color: #FFFFFF; color: #333333;
text-align: right;
}
.onoffswitch-switch {
display: block; width: 45px; margin: 0px;
background: #2E8DEF;
position: absolute; top: 0; bottom: 0;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
Button
a { font-size: 0; line-height: 0; text-indent: -4000px; background: #fff; border: 1px solid #007bff; width: 30px; height: 30px; display: block; position: relative; }
a:after { position: absolute; top: -1px; left: 30px; width: 30px; height: 30px; content: ''; display: block; background: #007bff; border: 1px solid #007bff; }
a:before { content: ''; display: block; width: 0; height: 0; border-style: solid; border-width: 10px 10px 0 10px; border-color: #007bff transparent transparent transparent; position: absolute; bottom: -10px; right: -25px; }
I am trying to draw a tip in CSS.
I have "middle success" so far, the only problem is that, depending on DIV width, the tip sometimes are not in the center position.
What I want:
My code so far:
.logo {
color: #000;
font-size: 1.4em;
text-align: center;
padding-top: 1.5em;
text-transform: uppercase;
position: relative;
}
.line {
height: 1px;
overflow: hidden;
background: #000;
}
.line.top,
.line.bottom {
width: 90%;
}
.line.top {
margin: 0 auto 4px;
}
.line.bottom {
margin: 4px auto 0;
}
.angle {
position: absolute;
top: 19px;
left: 46%; // I think my problem is here!
}
.angle .line.left,
.angle .line.right {
width: 20px;
}
.angle .line.left {
-ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
margin: 7px;
}
.angle .line.right {
-ms-transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
margin: -7px;
}
<div class="logo">
<div class="angle">
<div class="line left"></div>
<div class="line right"></div>
</div>
<div class="line top"></div>
MY TEXT
<div class="line bottom"></div>
</div>
How can I solve this?
I thought setting .angle width: 30px and margin: 0 auto, but it have position: absolute, so it is not possible.
Ps: LESS can be used.
No need of so many elements. Just use .logo element and its pseudo classes. and use letter-spacing css property to give space between the letters. (or use the exact font, if you know the name)
CSS
.logo {
color: #000;
font-size: 1.4em;
text-align: center;
height: 2em;
margin-top: 2em;
letter-spacing: 1em;
text-transform: uppercase;
line-height: 2em;
position: relative;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}
.logo::after, .logo::before {
content:"";
border-width: 20px;
border-style: solid;
position: absolute;
left: 50%;
bottom: 100%;
transform: translateX(-50%);
}
.logo::after {
border-width: 18px;
margin-bottom: 1px;
border-color: transparent transparent white transparent;
}
.logo::before {
border-color: transparent transparent black transparent;
}
Working Fiddle - using CSS
Working Fiddle - using SCSS
Nested Triangles!
.outer {
border: 40px solid transparent;
border-bottom: 40px solid black;
width: 0;
height: 0;
position: relative;
margin: 0 auto;
}
.inner {
border: 36px solid transparent;
border-bottom: 36px solid white;
width: 0;
height: 0;
position: absolute;
top: -32px;
left: -36px;
}
<div class="outer">
<div class="inner"></div>
</div>
You could just rotate a div and add a border to it. Then using z-indexing put it behind a div with just a top and bottom border holding your text. Might look something like this:
<!DOCTYPE html>
<html>
<head>
<style>
html{padding: 10px;}
.triangle {
width: 10%;
height: 10%;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
z-index: -1;
border-top: 1px solid black;
border-left: 1px solid black;
position: absolute;
top: 20px;
left: 45%;
}
.textBox {
height: 40px;
border-top: 1px solid black;
border-bottom: 1px solid black;
background: white;
z-index: 2;
text-align: center;
}
</style>
</head>
<body>
<div class="logo">
<div class="triangle"></div>
<div class="textBox">
MY TEXT
</div>
</div>
</body>
</html>
body{
margin-top:70px;
}
h2{
color:#fff;
text-align:center;
}
.arrow_box {
position: relative;
background: #88b7d5;
border: 4px solid #c2e1f5;
}
.arrow_box:after, .arrow_box:before {
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
border-color: rgba(136, 183, 213, 0);
border-bottom-color: #88b7d5;
border-width: 30px;
margin-left: -30px;
}
.arrow_box:before {
border-color: rgba(194, 225, 245, 0);
border-bottom-color: #c2e1f5;
border-width: 36px;
margin-left: -36px;
}
See working demo here.
I'd like to achieve something like this:
I've done this so far:
just wondering, how to make a purple area with little arrow button and once user click it, it would invoke something.
Here is the html and css code I have:
<div class="searchy">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch" value=""/>
</div>
CSS:
.searchy{
height: 60px;
background-color: #555;
color: #FFF;
margin-left: -15px;
margin-right: -15px;
}
.fdSearch{
background-color: white;
border-radius: 10px;
border: 5px solid #E5E4E2;
margin: 2px;
margin-left: -15px;
margin-right: -15px;
height: 40px;
vertical-align: middle;
padding: 20px;
margin-top: 15px;
width: 85%;
}
===================update==========================
Thank you guys....They all works. I just pick up one for the right answer.
I've learnt a lot from codes with different version of answers below. Thank you for your help again.
Fiddle: http://jsfiddle.net/hBdMz/
Css:
.form-wrapper {
width: auto;
padding:4px;
background: #555;
clear:both;
display:table;
}
/* Form text input */
.form-wrapper input {
width: 330px;
height: 20px;
padding: 10px 5px;
float: left;
border: 0;
background: white;
border-radius: 3px 0 0 3px;
outline:none;
}
/* Form submit button */
.form-wrapper button {
overflow: visible;
position: relative;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 40px;
width: 110px;
color: black;
text-transform: uppercase;
background: #9B30FF;
border-radius: 0 3px 3px 0;
text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
}
.form-wrapper button:before {
content: '';
position: absolute;
border-width: 8px 8px 8px 0;
border-style: solid solid solid none;
border-color: transparent #9B30FF transparent;
top: 12px;
left: -6px;
}
Html:
<div class="form-wrapper">
<input type="text" placeholder="Search here..." required>
<button type="submit">Search</button>
</div>
Adapted from: speckyboy
Check This Fiddle
HTML
<div class="searchy">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch"
value=""/>
<button type="submit">Submit</button>
</div>
CSS
.searchy {
background: grey;
padding: 50px 20px;
}
input {
border:none;
background: none;
border-top: 3px solid #e1e1e1;
border-left: 3px solid #e1e1e1;
border-bottom: 3px solid #e1e1e1;
padding: 10px 3px;
}
button {
border:none;
background: #4fd577;
padding: 9px 10px;
margin-left: -5px;
border-top: 3px solid #e1e1e1;
border-right: 3px solid #e1e1e1;
border-bottom: 3px solid #e1e1e1;
}
button { position: relative; background: #4fd577; }
button:after { right: 100%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; }
button:after { border-color: rgba(79, 213, 119, 0); border-right-color: #4fd577; border-width: 7px; top: 50%; margin-top: -7px; }
Use this tool to create css arrows :- http://cssarrowplease.com/
Inside your form create a division containing a division with the word SEARCH and an img with a unique class.
Position your out division to absolute, top minus the height of your textbox.
Float your Search division to the right, float, your img to the left.
Asign your search division a width and height.
http://jsfiddle.net/5BwLC/22/
HTML
<div class="searchy">
<div class="searc">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch" value=""/>
<div class="search-button" onclick="f()">
Search
</div>
</div>
</div>
CSS
.searchy{
min-height: 60px;
background-color: #555;
color: #FFF;
margin-left: -15px;
margin-right: -15px;
overflow:hidden;
}
.fdSearch{
float:left;
background-color: white;
border-radius: 10px;
border: 5px solid #E5E4E2;
margin: 2px;
margin-left: -15px;
margin-right: -15px;
min-height: 40px;
vertical-align: middle;
padding: 20px;
margin-top: 15px;
width: 85%;
}
.searc
{
width:85%;
overflow:hidden;
}
.search-button
{
margin-top:15px;
margin-left:-40px;
min-height:40px;
width:10%;
background-color:purple;
float:left;
padding:20px;
vertical-align: middle;
border-radius: 10px;
border: 5px solid #E5E4E2;
}
Would you like the arrow too?
demo: http://jsfiddle.net/gxXYC/
.searchy{
position:relative;
height: 60px;
width:480px;
background-color: #555;
color: #FFF;
}
.searchy:before, .searchy:after{
position:absolute;
top:0;
}
.searchy:before{
content:"";
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right:10px solid blue;
right:100px;
top:20px;
}
.searchy:after{
content: "search";
color:white;
text-align:center;
width: 96px;
height: 84%;
top: 5px;
font-size: 23px;
line-height: 44px;
background: blue;
right: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.fdSearch{
background-color: white;
border-radius: 10px;
border: 5px solid #E5E4E2;
height: 100%;
vertical-align: middle;
padding: 20px;
width: 100%;
float:left;
}
the markup
<div class="searchy">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch" value=""/>
</div>
if you want to use a submit button the git it an absolute position right width the same dimenssion as :after and an opacity :0;
http://jsfiddle.net/gxXYC/2/
Not sure why I'm adding my answer to the heaps, but here it is:
HTML:
<div class="searchy">
<div class="search-wrap">
<input type="search" name="ttsearch" data-style="mini" data-theme="d" placeholder="Search here..." class="fdSearch" value="" />
<button type="submit">Search</button>
</div>
</div>
CSS:
.searchy {
height: 60px;
background-color: #555;
color: #FFF;
position: relative;
padding: 0 6%;
}
.searchy:after {
content:'';
height: 100%;
display: inline-block;
vertical-align: middle;
}
.search-wrap {
background-color: white;
border-radius: 10px;
border: 5px solid #E5E4E2;
margin: 2px;
height: 40px;
vertical-align: middle;
width: 85%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
position: relative;
display: inline-block;
}
.search-wrap > input, .search-wrap > button {
margin: 0;
height: 100%;
border: 0;
}
.search-wrap input[type="search"] {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
width: 100%;
}
/* Unfortunately these have to be separate: http://css-tricks.com/snippets/css/style-placeholder-text/ */
.search-wrap input[type="search"]::-webkit-input-placeholder {
font-style: italic;
}
.search-wrap input[type="search"]:-moz-placeholder {
/* Firefox 18- */
font-style: italic;
}
.search-wrap input[type="search"]::-moz-placeholder {
/* Firefox 19+ */
font-style: italic;
}
.search-wrap input[type="search"]:-ms-input-placeholder {
font-style: italic;
}
.search-wrap button[type="submit"] {
position: absolute;
top: 0;
bottom: 0;
right: 0;
background: #7c7aa9;
color: #fff;
text-transform: uppercase;
padding: 0 10px;
}
.search-wrap button[type="submit"]:before {
position: absolute;
content:'';
border: 6px solid transparent;
border-right-color: #7c7aa9;
height: 0;
top: 0;
bottom: 0;
margin: auto 0;
left: -10px;
}
There's no one 'right' answer to this. Here's how I would do it:
Make the purple box/arrow a background image of the input.
Put the search text/button in an absolutely positioned DIV positioned above the right side of the input box.