I have a simple jQuery modal. It works well, but I can't set it horizontally middle. I've tried many approach, but it not centering anyway. It creates problem when I want to use "max-width: 400". It create problem and go on one side. I want to make it like bootstrap modal. Max-width: 400 and will be centered horizontally also. Please look at my code.
// common close button
$('.mi-modal-toggle').click(function() {
$(this).closest(".mi-modal").toggleClass('modal-visible');
});
// explicit button per modal
$('.mi-modal-toggle').on('click', function(e) {
var modalid = $(this).data("modal-id");
$(`.mi-modal[data-modal-id='${modalid}']`).toggleClass('modal-visible');
});
.mi-modal {
position: fixed;
z-index: 10000; /* 1 */
top: 0;
left: 0;
visibility: hidden;
height: 100%;
box-sizing: border-box;
padding: 10%;
width: 80%; /* 94% + 3% +3% = 100% */
max-width: 400px;
}
.mi-modal.modal-visible {
visibility: visible;
}
.mi-modal-overlay {
position: fixed;
z-index: 10;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: hsla(0, 0%, 0%, 0.4);
visibility: hidden;
opacity: 0;
transition: visibility 0s linear 0.3s, opacity 0.3s;
box-sizing: border-box;
}
.mi-modal.modal-visible .mi-modal-overlay {
opacity: 1;
visibility: visible;
transition-delay: 0s;
}
.mi-modal-wrapper {
position: absolute;
z-index: 9999;
top: 3em;
width: 100%;
background-color: #fff;
box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);
box-sizing: border-box;
margin: auto auto !important;
}
.mi-modal-transition {
transition: all 0.4s;
transform: translateY(-10%);
opacity: 0;
}
.mi-modal.modal-visible .mi-modal-transition {
transform: translateY(0);
opacity: 1;
}
.mi-modal-header,
.mi-modal-content {
padding: 1em;
}
.mi-modal-header {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: space-between;
position: relative;
background-color: #fff;
box-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.06);
border-bottom: 1px solid #e8e8e8;
}
.mi-modal-close {
margin: -0.5rem -0.5rem -0.5rem auto;
color: #aaa;
background: #edcfa5;
border: 0;
font-size: 20px;
font-weight: 700;
position: absoloute;
box-sizing: content-box;
width: 1em;
height: 1em;
padding: 0.3em;
color: #000;
border: 0;
border-radius: 0.25rem;
opacity: .5;
}
.mi-modal-close:hover {
color: #777;
}
.mi-modal-heading {
font-size: 1.125em;
margin: 0px 8px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.mi-modal-content>*:first-child {
margin-top: 0;
}
.mi-modal-content>*:last-child {
margin-bottom: 0;
}
.mi-modal.modal-scroll .mi-modal-content {
max-height: 60vh;
overflow-y: scroll;
}
.mi-modal.modal-scroll .mi-modal-wrapper {
position: absolute;
z-index: 9999;
top: 2em;
left: 50%;
width: 32em;
margin-left: -16em;
background-color: #CDf;
box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);
box-sizing: border-box;
}
.modal-footer {
display: flex;
flex-wrap: wrap;
flex-shrink: 0;
align-items: center; /* justify-content: flex-end; */
padding: 0.75rem;
border-top: 1px solid #dee2e6;
border-bottom-right-radius: calc(0.3rem - 1px);
border-bottom-left-radius: calc(0.3rem - 1px);
}
.modal-footer>* {
margin: 0.25rem;
}
<button class="mi-modal-toggle" data-modal-id="modal1">Show modal</button>
<div class="mi-modal" data-modal-id="modal1">
<div class="mi-modal-overlay mi-modal-toggle"></div>
<div class="mi-modal-wrapper mi-modal-transition">
<div class="mi-modal-header">
<h2 class="mi-modal-heading">This is a modal</h2>
<button class="mi-modal-close mi-modal-toggle">×</button>
</div>
<div class="mi-modal-body">
<div class="mi-modal-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit eum delectus, libero, accusantium dolores inventore obcaecati placeat cum sapiente vel laboriosam similique totam id ducimus aperiam, ratione fuga blanditiis maiores.</p>
</div>
</div>
<div class="modal-footer">
<button class="mi-btn btn-danger mi-ripple mi-ripple-light mi-modal-toggle">No</button>
<button class="mi-btn btn-info mi-ripple mi-ripple-light">Confirm</button>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Instead of wrestling with margin and padding for centering, just use the standard left position and -50% x-axis translation.
// common close button
$('.mi-modal-toggle').click(function() {
$(this).closest(".mi-modal").toggleClass('modal-visible');
});
// explicit button per modal
$('.mi-modal-toggle').on('click', function(e) {
var modalid = $(this).data("modal-id");
$(`.mi-modal[data-modal-id='${modalid}']`).toggleClass('modal-visible');
});
html,
body {
margin: 0;
padding: 0;
}
.mi-modal {
position: fixed;
z-index: 10000;
top: 0;
visibility: hidden;
height: 100%;
box-sizing: border-box;
width: 100%;
}
.mi-modal.modal-visible {
visibility: visible;
}
.mi-modal-overlay {
position: fixed;
z-index: 10;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: hsla(0, 0%, 0%, 0.4);
visibility: hidden;
opacity: 0;
transition: visibility 0s linear 0.3s, opacity 0.3s;
box-sizing: border-box;
}
.mi-modal.modal-visible .mi-modal-overlay {
opacity: 1;
visibility: visible;
transition-delay: 0s;
}
.mi-modal-wrapper {
position: absolute;
z-index: 9999;
top: 3em;
width: 100%;
max-width: 400px;
background-color: #fff;
box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);
box-sizing: border-box;
left: 50%;
transform: translateX(-50%);
}
.mi-modal-transition {
transition: all 0.4s;
transform: translate(-50%, -10%);
opacity: 0;
}
.mi-modal.modal-visible .mi-modal-transition {
transform: translate(-50%, 0);
opacity: 1;
}
.mi-modal-header,
.mi-modal-content {
padding: 1em;
}
.mi-modal-header {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: space-between;
position: relative;
background-color: #fff;
box-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.06);
border-bottom: 1px solid #e8e8e8;
}
.mi-modal-close {
margin: -0.5rem -0.5rem -0.5rem auto;
color: #aaa;
background: #edcfa5;
border: 0;
font-size: 20px;
font-weight: 700;
position: absoloute;
box-sizing: content-box;
width: 1em;
height: 1em;
padding: 0.3em;
color: #000;
border: 0;
border-radius: 0.25rem;
opacity: .5;
}
.mi-modal-close:hover {
color: #777;
}
.mi-modal-heading {
font-size: 1.125em;
margin: 0px 8px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.mi-modal-content>*:first-child {
margin-top: 0;
}
.mi-modal-content>*:last-child {
margin-bottom: 0;
}
.mi-modal.modal-scroll .mi-modal-content {
max-height: 60vh;
overflow-y: scroll;
}
.mi-modal.modal-scroll .mi-modal-wrapper {
position: absolute;
z-index: 9999;
top: 2em;
left: 50%;
width: 32em;
margin-left: -16em;
background-color: #CDf;
box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);
box-sizing: border-box;
}
.modal-footer {
display: flex;
flex-wrap: wrap;
flex-shrink: 0;
align-items: center;
/* justify-content: flex-end; */
padding: 0.75rem;
border-top: 1px solid #dee2e6;
border-bottom-right-radius: calc(0.3rem - 1px);
border-bottom-left-radius: calc(0.3rem - 1px);
}
.modal-footer>* {
margin: 0.25rem;
}
<button class="mi-modal-toggle" data-modal-id="modal1">Show modal</button>
<div class="mi-modal" data-modal-id="modal1">
<div class="mi-modal-overlay mi-modal-toggle"></div>
<div class="mi-modal-wrapper mi-modal-transition">
<div class="mi-modal-header">
<h2 class="mi-modal-heading">This is a modal</h2>
<button class="mi-modal-close mi-modal-toggle">×</button>
</div>
<div class="mi-modal-body">
<div class="mi-modal-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit eum delectus, libero, accusantium dolores inventore obcaecati placeat cum sapiente vel laboriosam similique totam id ducimus aperiam, ratione fuga blanditiis maiores.</p>
</div>
</div>
<div class="modal-footer">
<button class="mi-btn btn-danger mi-ripple mi-ripple-light mi-modal-toggle">No</button>
<button class="mi-btn btn-info mi-ripple mi-ripple-light">Confirm</button>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
For center alignment of modal add the following css code
.mi-modal.modal-visible {
margin: auto;
inset: 0;
}
.mi-modal-wrapper.mi-modal-transition {
top: 50%;
left: 50%;
transform: translate(-50%, -50%) !important;
}
// common close button
$('.mi-modal-toggle').click(function() {
$(this).closest(".mi-modal").toggleClass('modal-visible');
});
// explicit button per modal
$('.mi-modal-toggle').on('click', function(e) {
var modalid = $(this).data("modal-id");
$(`.mi-modal[data-modal-id='${modalid}']`).toggleClass('modal-visible');
});
.mi-modal {
position: fixed;
z-index: 10000; /* 1 */
top: 0;
left: 0;
visibility: hidden;
height: 100%;
box-sizing: border-box;
padding: 10%;
width: 80%; /* 94% + 3% +3% = 100% */
max-width: 400px;
}
.mi-modal.modal-visible {
visibility: visible;
}
.mi-modal-overlay {
position: fixed;
z-index: 10;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: hsla(0, 0%, 0%, 0.4);
visibility: hidden;
opacity: 0;
transition: visibility 0s linear 0.3s, opacity 0.3s;
box-sizing: border-box;
}
.mi-modal.modal-visible .mi-modal-overlay {
opacity: 1;
visibility: visible;
transition-delay: 0s;
}
.mi-modal-wrapper {
position: absolute;
z-index: 9999;
top: 3em;
width: 100%;
background-color: #fff;
box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);
box-sizing: border-box;
margin: auto auto !important;
}
.mi-modal-transition {
transition: all 0.4s;
transform: translateY(-10%);
opacity: 0;
}
.mi-modal.modal-visible .mi-modal-transition {
transform: translateY(0);
opacity: 1;
}
.mi-modal-header,
.mi-modal-content {
padding: 1em;
}
.mi-modal-header {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: space-between;
position: relative;
background-color: #fff;
box-shadow: 0 1px 2px hsla(0, 0%, 0%, 0.06);
border-bottom: 1px solid #e8e8e8;
}
.mi-modal-close {
margin: -0.5rem -0.5rem -0.5rem auto;
color: #aaa;
background: #edcfa5;
border: 0;
font-size: 20px;
font-weight: 700;
position: absoloute;
box-sizing: content-box;
width: 1em;
height: 1em;
padding: 0.3em;
color: #000;
border: 0;
border-radius: 0.25rem;
opacity: .5;
}
.mi-modal-close:hover {
color: #777;
}
.mi-modal-heading {
font-size: 1.125em;
margin: 0px 8px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.mi-modal-content>*:first-child {
margin-top: 0;
}
.mi-modal-content>*:last-child {
margin-bottom: 0;
}
.mi-modal.modal-scroll .mi-modal-content {
max-height: 60vh;
overflow-y: scroll;
}
.mi-modal.modal-scroll .mi-modal-wrapper {
position: absolute;
z-index: 9999;
top: 2em;
left: 50%;
width: 32em;
margin-left: -16em;
background-color: #CDf;
box-shadow: 0 0 1.5em hsla(0, 0%, 0%, 0.35);
box-sizing: border-box;
}
.modal-footer {
display: flex;
flex-wrap: wrap;
flex-shrink: 0;
align-items: center; /* justify-content: flex-end; */
padding: 0.75rem;
border-top: 1px solid #dee2e6;
border-bottom-right-radius: calc(0.3rem - 1px);
border-bottom-left-radius: calc(0.3rem - 1px);
}
.modal-footer>* {
margin: 0.25rem;
}
.mi-modal.modal-visible {
margin: auto;
inset: 0;
}
.mi-modal-wrapper.mi-modal-transition {
top: 50%;
left: 50%;
transform: translate(-50%, -50%) !important;
}
<button class="mi-modal-toggle" data-modal-id="modal1">Show modal</button>
<div class="mi-modal" data-modal-id="modal1">
<div class="mi-modal-overlay mi-modal-toggle"></div>
<div class="mi-modal-wrapper mi-modal-transition">
<div class="mi-modal-header">
<h2 class="mi-modal-heading">This is a modal</h2>
<button class="mi-modal-close mi-modal-toggle">×</button>
</div>
<div class="mi-modal-body">
<div class="mi-modal-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Impedit eum delectus, libero, accusantium dolores inventore obcaecati placeat cum sapiente vel laboriosam similique totam id ducimus aperiam, ratione fuga blanditiis maiores.</p>
</div>
</div>
<div class="modal-footer">
<button class="mi-btn btn-danger mi-ripple mi-ripple-light mi-modal-toggle">No</button>
<button class="mi-btn btn-info mi-ripple mi-ripple-light">Confirm</button>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Please see the image below.
contact-image
I want to make a contact container that has a square Contact header. I want the contact header in the middle of the container halfway out of the container. Problem is, both the header and the container have to be transparent and they have borders. The borders of the container cut right through the contact header. I'm having trouble removing the borders from inside the header.
<style>* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-size: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center;
padding-top: 30px;
padding-bottom: 20px;
}
.profile {
width: 480px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
ul {
list-style-type: none;
}
li {
display: inline;
}
.contact {
margin-bottom: 5px;
}
.container {
border: 2px solid gray;
}
.contact {
width: 40%;
margin-top: -23px;
border: 2px solid gray;
}
.header {
display: flex;
align-items: center;
justify-content: center;
}
h2 {
font-size: 25px;
text-align: center;
margin-top: 5px;
margin-bottom: 5px;
}
.container {
height: 380px;
}
.content {
width: 400px;
height: 70%;
margin: 0 auto;
}
.social {
display: flex;
align-items: center;
justify-content: center;
}
</style>
<div class="profile">
<section class="container">
<div class="header">
<div class="contact">
<h2>Contact</h2>
</div>
</div>
<div class="content">
<p class="about">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Recusandae distinctio libero repudiandae consequatur qui, vel ad error animi doloremque magni cupiditate officia officiis et? Vel voluptatem reiciendis placeat cumque officiis!</p>
</div>
<div class="social">
<ul>
<li>Twitter</li>
<li>Behance</li>
<li>Instagram</li>
</ul>
</div>
</section>
</div>
Just use <fieldset> and <legend>.
the legend is a title in a fieldset and the border of a fieldset will not go through the legend. The legend can be aligned with the margin.
fieldset {
border: 2px solid black;
min-height: 50vh;
}
legend {
border: 2px solid black;
margin: 0 auto;
padding: 5px 20px;
}
<fieldset>
<legend>Contact</legend>
</fieldset>
Adapted from another answer, you could try this instead of border-top:
body {
background: url('https://picsum.photos/536/354');
background-size: cover;
}
.header {
width: 240px;
border: 4px solid gray;
height: 50px;
margin: auto;
position: relative;
top: 25px;
padding: 10px;
text-align: center;
}
.box {
width: 350px;
height: 100px;
position: relative;
margin: auto;
border-left: 4px solid gray;
border-right: 4px solid gray;
border-bottom: 4px solid gray;
padding: 20px;
}
.box:after {
content: '';
width: 60px;
height: 4px;
background: gray;
position: absolute;
top: 0px;
left: 0;
}
.box:before {
content: '';
width: 60px;
height: 4px;
background: gray;
position: absolute;
top: 0px;
right: 0;
}
<div class="header">
title
</div>
<div class="box">
content
</div>
I'm using tailwind css, but I want to import some cards that I saw in a video. I know that I can use in class the after: attribute by tailwind, but its a waste of time when I already have it on css.
This cards are working perfectly without tailwind, but when I add the tailwind CSS a part of the :after is not working. I tried adding !important to the attributes but it still doesn't work.
How it shows with tailwind:
How it shows without tailwind:
My code:
.container {
position: relative;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
transform: skewY(-10deg);
}
.container .card {
position: relative;
width: 300px;
height: 400px;
background: white;
transition: 0.5s;
}
.container .card:before {
content: "";
position: absolute;
top: -15px;
left: 0;
width: 100%;
height: 15px;
background-color: #ddc700;
transform-origin: bottom;
transform: skewX(45deg);
transition: 0.5s;
}
.container .card:after {
content: "";
position: absolute;
top: -15px;
left: -15px;
width: 15px;
height: 50%;
background-color: #ddc700;
transform-origin: left;
transform: skewY(45deg);
transition: 0.5s;
border-bottom: 200px solid #d9d9d9;
}
.container .card:hover {
transform: translateY(-40px);
}
.container .card .imgBx {
position: relative;
width: 300px;
height: 200px;
background-color: #c6b200;
display: flex;
align-items: center;
flex-direction: column;
}
.container .card .imgBx img {
max-width: 100px;
}
.container .card .imgBx h3 {
position: relative;
color: black;
margin-top: 10px;
}
.container .card .content {
position: relative;
width: 100%;
height: 200px;
padding: 20px;
color: black;
background: white;
text-align: center;
}
.container .card .content:before {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 400px;
background: linear-gradient(transparent, transparent, gray);
transform-origin: bottom;
transform: skewX(45deg);
transition: 0.5s;
z-index: -1;
}
.container .card:hover .content:before {
transform: translateY(40px) skewX(45deg);
filter: blur(5px);
opacity: 0.5;
}
.container .card:nth-child(1) {
z-index: 3;
}
.container .card:nth-child(2) {
z-index: 2;
}
.container .card:nth-child(3) {
z-index: 1;
}
#media (max-width: 414px) {
body {
overflow: auto;
}
.card {
width: 80%;
margin-bottom: 50px;
}
.container {
padding-top: 200px;
position: relative;
left: 15%;
top: 80%;
}
.container .card {
padding-bottom: 40px;
}
.container .card:hover {
transform: translateY(-25px);
}
}
<head>
<!-- Styles -->
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="flex flex-col h-screen bg-black">
<div class="flex justify-center items-center text-center min-h-screen align-middle py-5 mb-3">
<div class="container">
<div class="card">
<div class="imgBx">
<h3>PUMP & DUMP</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
<div class="card">
<div class="imgBx">
<h3>PREVENTAS</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
<div class="card">
<div class="imgBx">
<h3>PASIVOS</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
</div>
</div>
</body>
</html>
Your problem is the height was only 50%
You need to make it like this
.container .card:after {
content: "";
position: absolute;
top: -15px;
left: -15px;
width: 15px;
height: 100%; /*Should change here from 50% to 100%*/
background-color: #ddc700;
transform-origin: left;
transform: skewY(45deg);
transition: 0.5s;
border-bottom: 200px solid #d9d9d9;
}
I have a division with class "centre" inside another division called "parallaxOne". With my css, if I view it in my laptop, it is showing the divisions properly, but if I view it in a mobile phone, the "centre" division is appearing outside the "parallaxOne" division, and in other browsers, it is appearing in front of the text. Why is this happening, and how do I correct it? Here is my code:
.centre {
position: absolute;
top: 75%;
left: 50%;
transform: translateY(-15%);
width: 0;
height: 140px;
border-left: 6px dashed #0079a5;
}
.arrow {
position: absolute;
top: 0;
left: -6px;
height: 40px;
width: 6px;
background: #007;
animation: animate 2s infinite;
}
.arrow:before {
content: '';
position: absolute;
bottom: 0;
left: -10px;
width: 20px;
height: 20px;
border-bottom: 6px solid #007;
border-right: 6px solid #007;
transform: rotate(45deg);
}
#keyframes animate {
0% {
transform: translateY(0);
opacity: 0.5;
}
50% {
transform: translateY(70px);
opacity: 1;
}
100% {
transform: translateY(140px);
opacity: 0;
}
}
.container {
max-width: inherit;
margin: 0 auto;
background-color: white;
font-size: 24px;
padding: 25px;
}
.parallaxOne {
background: /*url(images/parallax3.jpg); This is an image in my computer*/yellow;
text-align: center;
height: 450px;
padding: 2%;
margin: 2% 0;
}
.parallaxOne h6 {
color: black;
font-size: 200%;
margin: 8% 30%;
padding-top: 100px;
z-index: -1;
}
.parallaxTwo {
background: /*url('images/parallax2.jpg') no-repeat center; This is an image in my computer*/green;
background-size: cover;
background-attachment: fixed;
text-align: center;
height: 600px;
padding: 2%;
}
<html>
<head>
<title>My website</title>
</head>
<body>
<header>
<h1>My website</h1>
</header>
<div class="container">
<div class="parallaxOne">
<h3>Welcome to my website!</h3>
<div class="centre">
<div class="arrow"></div>
</div>
</div>
<div class="parallaxTwo">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
</body>
</html
I'm sorry for the long code, but I edited it as much as I could to reproduce the same problem.
Use this tag in your head section for responsive scaling your contents
<meta name="viewport" content="width=device-width, initial-scale=1">
In the snippet below, I have assigned a max-width of 400px to the tooltip. It width it has is much less than that. Why doesn't the tooltip have 400px width?
I do not want to explicitly assign it 400px as width because if the content is low, it should have 120px as the width (which is the min-width).
body {
display: flex;
justify-content: center;
height: 100vh;
align-items: center;
}
.select {
position: relative;
height: 30px;
background: black;
color: white;
padding: 10px 20px;
line-height: 30px;
}
.tooltip {
display: none;
}
.tooltip:after {
position: absolute;
bottom: 100%;
left: 100%;
margin-bottom: 30px;
margin-left: -20px;
display: block;
content: attr(title);
background: red;
color: white;
line-height: 16px;
font-size: 14px;
padding: 12px;
min-width: 120px;
max-width: 400px;
}
.tooltip:before {
position: absolute;
bottom: 100%;
left: 100%;
content: '';
height: 0;
width: 0;
border-top: 6px solid red;
border-bottom: 6px solid transparent;
border-left: 9px solid red;
border-right: 9px solid transparent;
margin-left: -20px;
margin-bottom: 21px;
}
.tooltip.active {
display: block;
}
<div class="select">
<div class="tooltip active" title="Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tempora quam, voluptatem aliquam quos, soluta nostrum repellat unde magni voluptatibus placeat vitae numquam voluptatum ab temporibus id illo. Voluptatem, iusto, incidunt?"></div>
I have a tooltip
</div>