Vertically Align <a> text inside a div - html

I am having trouble vertically aligning the 's text inside a div.
This is what I have. I need to center "Next" inside the blue box:
#import url(http://fonts.googleapis.com/css?family=Muli);
/*Makes the little side arrow*/
.open {
position: fixed;
width: 100px;
height: 40px;
left: 50%;
top: -1000px;
margin-left: -80px;
margin-top: -30px;
border: 1px solid #ccc;
background-color: #fff;
border-radius: 6px;
padding: 10px 30px;
color: #444;
transition: all ease-out 0.6s;
}
.open:hover {
border: 1px solid #aaa;
box-shadow: 0 0 8px #ccc inset;
transition: all ease-out 0.6s;
}
.tutorial-box {
position: fixed;
width: 400px;
height: 238px;
top: 75px;
background-color: #F3F3F3;
border-radius: 6px;
box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.4);
}
.slider-turn p, .tutorial-box h1{
margin-left: 10px;
}
.tutorial-box:before {
content: '';
position: absolute;
left: -14px;
top: 28px;
border-style: solid;
border-width: 10px 14px 10px 0;
border-color: rgba(0, 0, 0, 0) #f3f3f3 rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
}
.tutorial-box p {
width: 350px;
font-size: 16px;
color: #a8aab2;
font-weight: 400;
line-height: 28px;
float: left;
margin: 0;
}
.tutorial-box .bottom {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
width: 100%;
bottom: 0;
position: absolute;
}
.tutorial-box .bottom .btn-2 {
flex: 3;
-webkit-flex: 3;
-ms-flex: 3;
width: 100%;
height: 54px;
background-color: #373942;
border-bottom-left-radius: 6px;
display: flex;
}
.tutorial-box .bottom span {
flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
line-height: 54px;
color: #fff;
margin-left: 25px;
font-size: 18px;
}
.next {
text-decoration: none;
display: inline-block;
vertical-align: middle;
text-align: center;
flex: 1;
background-color: #6cb5f3;
border: 0;
margin: 0;
padding: 0;
text-transform: uppercase;
color: #fff;
font-weight: bold;
border-bottom-right-radius: 6px;
cursor: pointer;
transition: all .3s;
}
.next:hover {
text-decoration: none;
background-color: #6BA5D6;
transition: all .3s;
}
.next:active {
text-decoration: none;
background-color: #5F8AAF;
}
.slider-tutorial-box {
width: 350px;
margin: 0 25px;
overflow: hidden;
}
.slider-turn {
width: 10000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- TUTORIAL -->
<div class="tutorial-box">
<h1>Welcome</h1>
<span class="close"></span>
<div class="slider-container">
<div class="slider-turn">
<p>
Here, under the Company tab, is where you will do most of the company managment.<br>
</p>
</div>
</div>
<div class="bottom">
<div class="btn-2">
<span>Step 2/?</span>
</div>
Next
</div>
</div>
Please let me know how I can center the text vertically to the center of the div.
Thank you very much. Let me know if I wasn't clear enough.

Seems like you already did that for .tutorial-box .bottom span so, do the same thing for .next
.next{
line-height: 54px;
}

the simplest and possibly most easy way would be to add the 'center' and '/center' tag before and after the text you want, and after each letter use '/br' to move to the next line. this will add some bulk, but would be considerably easier than other methods.
<center>
'letter'</br>'next letter'</br>'next letter'</br>
</center>
repeating the letter and break for all letters

alternatively, you could also add "div" tags around the "a" tag. you would have to modify the 'height' and 'width' to make it vertical for you. I would use px for this and not '%' or 'em'. add this to them:
<div style="height: /* modify this */100px; width: /* and this*/20px;">
Next
</div>
this may not be AS compatible cross platform though.

Like this:
.next {
position: relative;
top: 50%;
transform: translateY(-50%);
}
A nice trick that works both vertically and horizontally.

Related

How to align text inside link to bottom corner?

I have a card that needs to be covered by link and have text at the bottom corner. Currently text is located at the top, how can I move it to the bottom while keeping link covering card?
.card{
background-color: #fff;
border-radius: 4px;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
width: 200px;
height: 250px;
padding: 10px;
position: relative;
}
.card a {
color: red;
text-decoration: none;
padding: 10px;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.card a:hover {
cursor: pointer;
text-decoration: underline;
}
<div class='card'>
<p>Some description goes here</p>
<a href='#'>Read more</a>
</div>
It is usually called stretched link (for example in Bootstrap) and it uses pseudo (before/after) elements which are absolute while the original element can be somewhere else.
To place link at the bottom of the card (without using absolute position) I've set flex to .card and margin-top: auto to a.
Something like this:
.card {
display: flex;
flex-flow: column;
background-color: #fff;
border-radius: 4px;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
width: 200px;
height: 250px;
padding: 10px;
position: relative;
}
.card a {
color: red;
text-decoration: none;
margin-top: auto;
}
/* ↓↓ this is it ↓↓ */
.card a:after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
content: "";
}
.card a:hover {
cursor: pointer;
text-decoration: underline;
}
<div class='card'>
<p>Some description goes here</p>
<a href='#'>Read more</a>
</div>

CSS placement: Horizontal and vertical placement of a text and a button

I'm struggling with a CSS placement problem.
For a project I use clipboard.js to copy the content of a p tag.
In a div, I have my text on the left and a button on the right with an icon to copy the text. The size of the text is dynamic and I cut the text if it exceeds the length of the div.
I'm looking for a :
1 - Align the text vertically (on several lines if the text is too long)
2 - Put the button on the right with a margin on the left.
3 - center the button vertically
I managed to put the text and the button on one line with the display: inline-block property but both the button and the text are not vertically centered.
Here is my code: https://jsfiddle.net/n70jrymp/
See if this is what you looking for, i changed the display: inline-block for flex and centered the content.
#container {
width: 80% !important;
margin-left: 10%;
}
#result{
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
.resultItem {
display: flex;
border: 1px solid black;
background: white;
max-width: 100%;
width: 100%;
color: black;
line-height: 100%;
align-items: center;
justify-content: center;
}
.resultItem>p {
display: inline-block;
width: calc(100% - 60px);
overflow-wrap: anywhere;
margin: 0;
}
.resultItem>.clippy {
display: inline-block;
margin-bottom: 0;
width: 40px;
height: 40px;
cursor: pointer;
background-color: #fff;
background-image: url("https://abs.twimg.com/emoji/v1/72x72/1f4cb.png");
/* Twitter clipboard emoji */
background-size: 60% auto;
background-position: center center;
background-repeat: no-repeat;
border: 1px solid rgba(0, 0, 0, 0.29);
border-bottom-color: rgba(0, 0, 0, 0.36);
border-radius: 3px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}
.clippy:before {
content: '';
display: none;
position: absolute;
z-index: 9998;
top: 35px;
left: 15px;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid rgba(0, 0, 0, 0.72);
}
.clippy:after {
content: 'Copy to Clipboard';
display: none;
position: absolute;
z-index: 9999;
top: 40px;
left: -37px;
width: 124px;
height: 36px;
color: #fff;
font-size: 10px;
line-height: 36px;
text-align: center;
background: rgba(0, 0, 0, 0.72);
border-radius: 3px;
}
.clippy:hover {
background-color: #eee;
}
.clippy:hover:before,
.clippy:hover:after {
display: block;
}
.clippy:active,
.clippy:focus {
outline: none;
}
.clippy:active:after,
.clippy:focus:after {
content: 'Copied!';
}
<link rel="stylesheet" href="test.css">
<link rel="stylesheet" href="https://unpkg.com/mustard-ui#latest/dist/css/mustard-ui.min.css">
<div id="container">
<div id="result">
<div class="resultItem" id="test">
<p>My wonderful strzfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddstrzfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddstrzfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddstrzfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddstrzfddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddstrzfdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd</p>
<button class="clippy" data-clipboard-target="#test"></button>
</div>
</div>
</div>

How to make line between two circles which touching to the both circle?

I want to make a line between two circles, for that, I have used the below code by using pseudo-element CSS. I would like to make the line between these two circles responsive, now it's intersecting with circle in some other devices like mobile, etc. How to make it responsive or any other solution that does the same design? Please help.
.cart_header_tab {
display: flex;
margin-top: 35px;
}
.cart_header_tab > div {
text-align: center;
margin-right: 100px;
cursor: pointer;
}
.cart_header_tab h6 {
color:#02b5f9;
font-weight: 400;
}
.cart_header_tab div:last-child h6 {
color:#ccc
}
span.circle_one::after {
content: "";
width: 152px;
height: 1px;
background: #eee;
position: absolute;
top: 6px;
left: 14px;
}
.cart_header_tab span.circle_one {
border: 1px solid #2fe4ba;
}
.cart_header_tab span {
display: inline-block;
width: 16px;
height: 16px;
border: 1px solid #ccc;
border-radius: 100%;
position: relative;
}
<div class="cart_header_tab">
<div>
<span class="circle_one"></span>
<h6>Order Details</h6>
</div>
<div>
<span class="circle_two"></span>
<h6>Freight Options</h6>
</div>
</div>
You can start tweaking the code something like this:
Be aware that if you wanted to change the size or width of the circle you have to tweak the other property in the css, hope that is not an issue here.
#cart_header_tab {
position: relative;
display: inline-block;
}
#cart_header_tab::after {
content: "";
position: absolute;
width: 50%;
z-index: -1;
top: 20%;
left: 25%;
border: 1px solid gray;
/* line between circles */
}
#cart_header_tab div {
display: inline-block;
font-size: 12px;
text-align: center;
min-width: 150px;
}
#cart_header_tab span {
color: white;
background: white;
display: block;
height: 15px;
margin: 0 auto 10px;
padding-top: 20px;
width: 30px;
border-radius: 50%;
border: 1px solid #22A7F2;
}
<div id="cart_header_tab">
<div><span class="circle_one"></span>
<h6>Order Details</h6>
</div>
<div><span class="circle_two"></span>
<h6>Freight Options</h6>
</div>
</div>
Using flex i insert that line between circle as separator itself is a child of flex and hen using margin adjust that according to circles
.cart_header_tab {
display: flex;
margin-top: 35px;
}
.cart_header_tab>div {
text-align: center;
cursor: pointer;
}
.cart_header_tab h6 {
color: #02b5f9;
font-weight: 400;
}
.cart_header_tab div:last-child h6 {
color: #ccc
}
.cart_header_tab {
position: relative
}
.sep {
width: 100%;
height: 1px;
background: #eee;
margin: 9px -21px 0;
}
.cart_header_tab span.circle_one {
border: 1px solid #2fe4ba;
background: #fff;
z-index: 1;
}
.circle_two {
background: #fff;
z-index: 1;
}
.cart_header_tab span {
display: inline-block;
width: 16px;
height: 16px;
border: 1px solid #ccc;
border-radius: 100%;
position: relative;
}
<div class="cart_header_tab">
<div>
<span class="circle_one"></span>
<h6>Order Details</h6>
</div>
<div class="sep"></div>
<div>
<span class="circle_two"></span>
<h6>Freight Options</h6>
</div>
</div>

Create three vertical dots (ellipsis) inside a circle

I want to make a circle <div>, like this image:
I have tried this code.
.discussion:after {
content: '\2807';
font-size: 1em;
background: #2d3446;
width: 20px;
height: 20px;
border-radius: 100px;
color:white;
}
<div class="discussion"></div>
How can I do this correctly?
You could just use :after pseudo-element with content: '•••' and transform: rotate. Note that this is the bullet HTML special character •, or \u2022.
div {
position: relative;
background: #3F3C53;
width: 50px;
height: 50px;
color: white;
border-radius: 50%;
box-shadow: 0px 0px 15px 1px #4185BC;
margin: 50px;
}
div:after {
content: '•••';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(90deg);
font-size: 15px;
letter-spacing: 4px;
margin-top: 2px;
}
<div></div>
Improving on Nenad Vracar's answer, here's one that doesn't use text (so it's font-independent) and everything is centered nicely:
div {
position: relative;
background: #3F3C53;
width: 50px;
height: 50px;
border-radius: 50%;
box-shadow: 0px 0px 15px 1px #4185BC;
margin: 50px;
}
div:after {
content: '';
position: absolute;
left: 50%;
top: 50%;
width: 2px;
height: 2px;
margin-left: -1px;
margin-top: -1px;
background-color: white;
border-radius: 50%;
box-shadow: 0 0 0 2px white, 0 11px 0 2px white, 0 -11px 0 2px white;
}
<div></div>
Yet another answer, same as others except:
it uses the vertical ellipsis character (U+22EE)
text-align and line-height to center the content
does not use any pixel value
.discussion:after {
content: "\22EE";
/* box model */
display: inline-block;
width: 1em;
height: 1em;
/* decoration */
color: #FFFFFF;
background-color: #000000;
border-radius: 50%;
/* center align */
line-height: 1;
text-align: center;
}
<div class="discussion"></div>
<div class="discussion" style="font-size: 2em;"></div>
<div class="discussion" style="font-size: 3em;"></div>
<div class="discussion" style="font-size: 4em;"></div>
Note that U+2807 is actually a Braille pattern and the dots are not supposed to be centered.
Use this code.
.discussion {
width: 20px;
height: 20px;
border-radius: 50%;
position: relative;
background: #2d3446;
}
.discussion:after {
content: '\22EE';
font-size: 1em;
font-weight: 800;
color: white;
position: absolute;
left: 7px;
top: 1px;
}
<div class="discussion"></div>
Hope this helps!
I hope this is what you wanted! Otherwise feel free to ask.
.discussion{
display: block; /* needed to make width and height work */
background: #2d3446;
width: 25px;
height: 25px;
border-radius: 100px;
display: flex;
align-items: center;
justify-content: center;
}
.discussion:after {
content: '\2807';
font-size: 1em;
color: white;
margin-left: 15%;
}
<div class="discussion"></div>
Using text dots
.discussion{
width:50px;
height:50px;
text-align:center;
background-color:black;
border: 2px solid red;
border-radius: 100%;
}
.discussion text{
writing-mode: tb-rl;
margin-top:0.4em;
margin-left:0.45em;
font-weight:bold;
font-size:2em;
color:white;
}
<div class="discussion"><text>...</text></div>
.discussion:after {
content: '\2807';
font-size: 1em;
display: inline-block;
text-align: center;
background: #2d3446;
width: 20px;
height: 20px;
border-radius: 50%;
color: white;
padding:3px;
}
<div class="discussion"></div>
I have deleted (i found how to do it) all my post, the following code works for 3 vertical dot into a black circle
.discussion:after{
display:inline-block;
content:'\22EE';
line-height:100%;
border-radius: 50%;
margin-left:10px;
/********/
font-size: 1em;
background: #2d3446;
width: 20px;
height: 20px;
color:white;
}
<div class="discussion"></div>

How do I draw a horizontal line between two circles with CSS?

How do I draw a horizontal line in between 2 circles in CSS?
It has to be in the middle of them just as shown in the screenshot.
Example here:
I have drawn the 2 circles, but don't know how to connect them.
#status-buttons a {
color: black;
display: inline-block;
font-size: 17px;
font-weight: normal;
margin-right: 0;
text-align: center;
text-transform: uppercase;
min-width: 150px;
text-decoration: none;
}
#status-buttons a:hover {
text-decoration: none;
}
#status-buttons a.active span {
color: white;
background: #ACCF5B;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
#status-buttons span {
color: white;
background: #22bacb;
display: block;
height: 45px;
margin: 0 auto 10px;
padding-top: 20px;
width: 60px;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
<div id="status-buttons" class="text-center">
<span>1</span> Step 1
<span>2</span> Step 2
</div>
See demo on JSFiddle
You can use a pseudo-element to insert an absolutely-positioned border:
#status-buttons {
position: relative; /* 1 */
display: inline-block; /* 2 */
}
#status-buttons::after { /* 3 */
content: "";
position: absolute;
width: 50%;
z-index: -1; /* 4 */
top: 35%;
left: 25%;
border: 3px solid #ACCF5B;
}
#status-buttons a {
color: black;
display: inline-block;
font-size: 17px;
font-weight: normal;
margin-right: 0;
text-align: center;
text-transform: uppercase;
min-width: 150px;
text-decoration: none;
}
#status-buttons a:hover {
text-decoration: none;
}
#status-buttons a.active span {
color: white;
background: #ACCF5B;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
#status-buttons span {
color: white;
background: #22bacb;
display: block;
height: 45px;
margin: 0 auto 10px;
padding-top: 20px;
width: 60px;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
<div id="status-buttons" class="text-center">
<span>1</span> Step 1
<span>2</span> Step 2
</div>
Notes:
Establish nearest positioned ancestor for absolute positioning.
Make container consume only the width necessary.
Insert pseudo element
Ensure that any horizontal line overlap doesn't appear above circles
You can add a new element and position it between the two circles:
#status-buttons a {
color: black;
display: inline-block;
font-size: 17px;
font-weight: normal;
margin-right: 0;
text-align: center;
text-transform: uppercase;
min-width: 150px;
text-decoration: none;
}
#status-buttons a:hover {
text-decoration: none;
}
#status-buttons a.active span {
color: white;
background: #ACCF5B;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
#status-buttons span {
color: white;
background: #22bacb;
display: block;
height: 45px;
margin: 0 auto 10px;
padding-top: 20px;
width: 60px;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
#line {
position: absolute;
top: 42px;
left: 112px;
width: 96px;
height: 5px;
background: #ACCF5B;
}
<div id="status-buttons" class="text-center">
<span>1</span> Step 1
<div id="line">
</div>
<span>2</span> Step 2
</div>
Here is one solution:
https://jsfiddle.net/sfyuxrs9/
It contains a div (which forms the line) which has position: absoluteand a negative z-index value. The rest ist just adjusting all the values for width/height/top and left
Here's the cleanest solution with flex
.timeline {
display: flex;
align-items: center;
justify-content: center;
}
.circle {
width: 13px;
height: 13px;
background: black;
border-radius: 50%;
}
.dashed {
width: 100px;
border: 1px dashed #C4C4C4;
}
<div class="timeline">
<div class="circle"></div>
<div class="dashed"></div>
<div class="circle"></div>
<div class="dashed"></div>
<div class="circle"></div>
</div>
I guess you can do some thing like this
check the following code snippet
#status-buttons a {
color: black;
display: inline-block;
font-size: 17px;
font-weight: normal;
margin-right: 0;
text-align: center;
text-transform: uppercase;
min-width: 150px;
text-decoration: none;
}
#status-buttons a:hover {
text-decoration: none;
}
#status-buttons a.active span {
color: white;
background: #ACCF5B;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
#status-buttons span {
color: white;
background: #22bacb;
display: block;
height: 45px;
margin: 0 auto 10px;
padding-top: 20px;
width: 60px;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
div.linetop { border-top: 1px solid #111111; width:95px;
position:absolute;
top:40px;
left:115px;
}
<div id="status-buttons" class="text-center">
<span>1</span> Step 1
<span>2</span> Step 2
</div>
<div class="linetop"></div>
Hope this helps
Here you go.
<div id="status-buttons" class="text-center">
<span>1</span> Step 1
<span>2</span> Step 2
</div>
<div class="line">
</div>
The CSS
#status-buttons a {
position: relative;
color: black;
display: inline-block;
font-size: 17px;
font-weight: normal;
margin-right: 0;
text-align: center;
text-transform: uppercase;
min-width: 150px;
text-decoration: none;
z-index: 1;
}
#status-buttons a:hover {
text-decoration: none;
}
#status-buttons a.active span {
color: white;
background: #ACCF5B;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
#status-buttons span {
color: white;
background: #22bacb;
display: block;
height: 45px;
margin: 0 auto 10px;
padding-top: 20px;
width: 60px;
border-radius: 50%;
box-shadow: rgba(0, 0, 0, 0.792157) 3px 3px 3px 0;
}
.line {
position: absolute;
border-bottom: 5px solid black;
width: 20%;
left: 71px;
top: 39px;
z-index: 0;
}
https://jsfiddle.net/norcaljohnny/nwjz2010/
You can also use this method :)
.his-bar { display: flex; position: relative; padding-top: 50px; width: 100%; margin:auto; margin-top: 40px; }
.his-bar:before { content: ''; border: 1px solid #727272; position: absolute; top: 60px; right: 0; width: 99%; }
.his-bar .point { border: 2px solid #872071; width: 20px; height: 20px; border-radius: 50%; display: inline-block; background-color: #F8F8F8; z-index: 2; position: relative; }
.his-bar .point-start:after { content: '2000'; position: absolute; top: 30px; left: -7px; }
.his-bar .point-end { margin-left: auto; }
.his-bar .point-end:after { content: '2021'; position: absolute; top: 30px; left: -7px; }
<div class="his-bar">
<span class="point point-start"></span>
<span class="point point-end"></span>
</div>