CSS Fixed Element Positioning and Link - html

I have two questions...
How do I make the #LeftTable and drop-down menu to keep their position on the page, regardless of the window size?
As it is right now, it will move to be relative to the size of the window. I'd rather it stay in exactly the same place on the background picture (even if it means having scrolling bars at the bottom of the browser). How do I do this?
How do I get the HTML link to work within the button?
body {
background-color: gray;
background-image: url('images/backgroundpic.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
ul {
list-style-type: none;
position: fixed;
bottom: 0;
margin: 0;
padding: 0;
background-color: #333;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: #87cefa;
}
li.dropdown {
display: inline-block;
}
ul li {
position: relative;
}
.dropdown-content {
display: none;
position: absolute;
bottom: 30px;
left: 0;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #f1f1f1
}
.dropdown:hover .dropdown-content {
display: block;
}
input#gobutton {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) cursor: pointer;
padding: 5px 25px;
background: #87CEFA;
border: 1px solid #1E90FF;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 4px rgba(0, 0, 0, .75);
box-shadow: 0 0 4px rgba(0, 0, 0, .75);
color: #f3f3f3;
font-size: 1.1em;
}
input#gobutton:hover,
input#gobutton:focus {
background-color: #000080;
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, .75);
box-shadow: 0 0 1px rgba(0, 0, 0, .75);
}
#LeftTable {
position: absolute;
width: 25%;
min-width: 25%;
right: 75%;
left: 25%;
top: 25%;
bottom: 50%;
Right: 100px;
border: 1px;
color: black;
font-weight: bold;
background-color: white;
opacity: 0.5;
filter: alpha(opacity=50);
border: 1px solid black;
padding: 5px;
}
<table id = "LeftTable">
<tr>
<td width = "20%"></td>
<td width = "80%" id='test'>
<table>
<tr><td>Left</td></tr>
<tr><td>Left</td></tr>
</table>
</td>
</tr>
</table>
<table class="gobutton" align="center">
<tr>
<td>
<div class="b_left"></div>
<div class="b_middle">
<input id="gobutton" type="submit" value="LISTEN" />
<a href="http://www.google.com">
</a>
</div>
<div class="b_right"></div>
</div>
</td>
</tr>
</table>

For your link:
You link works however in your example it's trying to open in a frame so its failing. If you create a html file on your computer, or host the html on a site it should work. I tested this on my computer and the link does work like this:
<a href="http://www.google.com">
<input id="gobutton" type="submit" value="LISTEN" />
</a>
For your table
if you want the position to never change you should not use percentages you should use measurements like pixels.
so instead of
#LeftTable {
position: absolute;
width: 25%;
min-width: 25%;
right: 75%;
left: 25%;
top: 25%;
...
you would have something like:
#LeftTable {
position: absolute;
width: 25%;
min-width: 25%;
right: 50px; //in pixels
left: 50px; //in pixels
top: 50px; //in pixels
...
also you may have to wrap your tables in a div and apply the background to that if you want the image t move with the left table:
<div class="main">
//tables
</div>
.main{
background-image: url('imageurl');
width:100%;
height:100%;
position: absolute;
bottom: 0;
margin: 0;
}
here's an example: http://codepen.io/nilestanner/pen/EgNXwE

Related

Modal-Overlay issue

First of all excuse me for explanation if I am not up to the mark, as this is my first post in this platform, Well, I am working on overlay where it has to be shown in right side of the page with given width of say 416px and 100vh of height, but things are getting cut if I do decrease the browser window and as I am decreasing the size of the browser window the button at bottom start appearing on content of overlay which has to remain at bottom even the height is getting decreased, here is the my code as below:
.advanced-overlay {
width: 100%;
min-height: 100vh;
background-color: rgba(35, 0, 18, 0.5);
position: fixed;
z-index: 100002;
top: -41px;
left: 0;
bottom: 0;
.advance-overlay-footer {
display:flex;
justify-content: space-between;
align-items:center;
position: fixed;
right: 24px;
width:156px;
bottom: 24px;
height:6%;
}
.advanced-overlay-content {
position: relative;
// min-height: 83vh;
width: 416px;
margin-top: 108px;
margin-left: auto;
margin-right: 6px;
opacity: 1;
z-index: 100004;
border-radius: 16px 16px 16px 16px;
background-color: #f5f4f6;
box-shadow: 0 2px 30px 0 rgba(0, 0, 0, 0.07),
0 19px 18px 0 rgba(0, 0, 0, 0.05), 0 8px 12px 0 rgba(0, 0, 0, 0.05),
0 1px 5px 0 rgba(0, 0, 0, 0.04), 0 0 2px 0 rgba(0, 0, 0, 0.03);
.close-advance-overlay {
position: absolute;
background-color: #fff;
width: 110px;
height: 40px;
display: flex;
border-radius: 20px;
padding: 5px 22px;
top: -18px;
right: 155px;
opacity: 1;
cursor: pointer;
img {
height: 20px;
width: 20px;
align-self: center;
}
.button-text {
align-self: center;
margin-left: 5px;
font-weight: 600;
font-size: 16px;
color: #000000;
}
}
.advnaced-overlay-content-secion {
//min-height:89vh;
width: 100%;
bottom:10%;
// height:100vh;
.select-box {
margin-top: 40px;
margin-bottom: 40px;
}
.accordinan-filter {
margin-bottom: 24px;
}
.accordian-title {
font-weight: 900;
}
.accordian-content {
margin: 0;
font-size: 16px;
}
}
}
}
.is-maximum {
height: 73vh;
overflow-y: auto;
overflow-x: hidden;
&::-webkit-scrollbar {
width: 4px;
background-color: #fff;
}
&::-webkit-scrollbar-thumb {
border-radius: 3px;
background-color: #d3d3d3;
}
}
<div class="advanced-overlay" v-if="toggleFilter">
<div class="advanced-overlay-content">
<div class="close-advance-overlay" #click="toggleAdvanceFilterOverlay">
<img class src="../assets/icons/close.svg" />
<span class="button-text">Close</span>
</div>
<div class="advnaced-overlay-content-secion is-maximum">
<div class="select-box"></div>
<div class="accordinan-filter"></div>
</div>
<div class="advance-overlay-footer">...two buttons</div>
</div>
</div>
So, I what I would like to achieve eventually is that, I want respsonsive overlay at right side of the browser window, provided if I am decreasing height of the browser the buttons at bottom should stay there (fixed position) and content should be within limit of .advnaced-overlay-content-secion
for a responsive design I recommend you to read into the use of grid and espacially for mobile designs also the use of #media breakpoints.
for having some thing to stick at the bottom simply use:
position: fixed;
bottom: 0;

Div keeps overflowing onto other elements when zoomed in

I'm trying to make a small web page with a search bar and an accounts menu (currently just a circle), but I've noticed, when I zoom in, or resize the page, the accounts menu overflows onto the search bar. I've tried changing from absolute positioning, to relative and adjusting the right: 30px accordingly, but this didn't work. I'm incredibly stuck, can anyone offer any advice/code?
body {
font-family: "PT-Sans", sans-serif;
background-color: #bbb;
}
input:focus {
outline: none;
}
.search-btn {
border: none;
padding: 12px;
font-size: 18px;
background-color: #009AFF;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
color: white;
width: 70px;
position: relative;
right: 5px;
cursor: pointer;
}
.input {
width: 500px;
padding: 11px;
font-size: 18px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
border: 1px solid #777;
}
.search {
width: 600px;
position: absolute;
left: 200px;
top: 15px;
}
.logo a {
color: #009AFF;
font-size: 38px;
text-decoration: none;
}
.logo {
position: absolute;
left: 0;
top: 12px;
width: 200px;
}
.content {
width: 300px;
border: 2px solid #eee;
background-color: #fff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
top: 65px;
padding: 5px;
}
#account-items {
display: none;
background-color: #fff;
width: 300px;
border: 2px solid #eee;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
position: absolute;
right: 0px;
top: 72px;
padding: 5px;
}
/*.accounts:hover #account-items {
display: inline;
}*/
#account-items a {
color: #009AFF;
text-decoration: none;
display: block;
padding: 5px;
padding-left: 10px;
padding-right: 10px;
}
#account-items a:hover {
background-color: #eee;
}
.accounts {
cursor: pointer;
position: absolute;
right: 30px;
width: 66px;
height: 66px;
top: 4px;
padding: 0px;
border-radius: 100%;
}
.accounts .image {
background-image: url("/email/scripts/profile.png");
background-size: 100%;
background-repeat: no-repeat;
border: 1px solid #777;
border-radius: 100%;
width: 63px;
height: 63px;
}
a {
color: #009AFF;
text-decoration: none;
}
.js-is-hidden {
display: none;
}
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="body">
<div class="header">
<div class="logo">
<center>Unnamed</center>
</div>
<div class="search">
<form action="search.php" method="GET">
<input type="text" name="q" class="input" autocomplete="off" />
<button type="submit" class="search-btn">Go</button>
</form>
</div>
<div class="accounts">
<div class="image">
</div>
</div>
</div>
</div>
If you remove the absolute positioning and stick with the default relative, then use a display of inline-block (Read up on what it does here: https://www.w3schools.com/css/css_inline-block.asp) and use dynamic widths instead of static ones, you should get your desired result.
See the updated code below;
body {
font-family: "PT-Sans", sans-serif;
background-color: #bbb;
}
input:focus {
outline: none;
}
.search-btn {
border: none;
padding: 12px;
font-size: 18px;
background-color: #009AFF;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
color: white;
width: 70px;
position: relative;
right: 5px;
cursor: pointer;
}
.input {
width: calc(100% - 100px); /* CHANGED */
padding: 11px;
font-size: 18px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
border: 1px solid #777;
}
.search {
max-width: 600px; /* CHANGED */
width: calc(100% - 300px); /* ADDED */
/* position: absolute; REMOVED */
/* left: 200px; REMOVED */
/*top: 15px; REMOVED */
display: inline-block; /* ADDED */
vertical-align: middle; /* ADDED */
}
.logo a {
color: #009AFF;
font-size: 38px;
text-decoration: none;
}
.logo {
/*position: absolute; //REMOVED */
/*left: 0; //REMOVED */
display: inline-block; /* ADDED */
vertical-align: middle; /* ADDED */
top: 12px;
width: 200px;
}
.content {
width: 300px;
border: 2px solid #eee;
background-color: #fff;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
top: 65px;
padding: 5px;
}
#account-items {
display: none;
background-color: #fff;
width: 300px;
border: 2px solid #eee;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
position: absolute;
right: 0px;
top: 72px;
padding: 5px;
}
/*.accounts:hover #account-items {
display: inline;
}*/
#account-items a {
color: #009AFF;
text-decoration: none;
display: block;
padding: 5px;
padding-left: 10px;
padding-right: 10px;
}
#account-items a:hover {
background-color: #eee;
}
.accounts {
cursor: pointer;
/* position: absolute; REMOVED */
/* right: 30px; REMOVED */
width: calc(100% - 809px); /* CHANGED */
height: 66px;
/* top: 4px; REMOVED */
padding: 0px;
border-radius: 100%;
display: inline-block; /* ADDED */
vertical-align: middle; /* ADDED */
text-align: right; /* ADDED */
}
.accounts .image {
background-image: url("/email/scripts/profile.png");
background-size: 100%;
background-repeat: no-repeat;
border: 1px solid #777;
border-radius: 100%;
width: 63px;
height: 63px;
display: inline-block; /* ADDED */
}
a {
color: #009AFF;
text-decoration: none;
}
.js-is-hidden {
display: none;
}
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="body">
<div class="header">
<div class="logo">
<center>Unnamed</center>
</div>
<div class="search">
<form action="search.php" method="GET">
<input type="text" name="q" class="input" autocomplete="off" />
<button type="submit" class="search-btn">Go</button>
</form>
</div>
<div class="accounts">
<div class="image">
</div>
</div>
</div>
</div>
try this
.header {
position: relative;
min-width: 900px;
}
https://jsfiddle.net/59ncte3m/1/
It will avoid the issue where your menu gets drawn on top of the search by making the header a positioned element, the menu absolute position will be relative to the header. giving it a min-width will make sure all elements fit within.
This is still not a good responsive design, as it should avoid pixel dimentions, but it is enough to fix the overflowing issue.

how can I vertically align a google icon within a button? (ie11)

I have trouble with vertical alignment of some google icons inside buttons. I tried to play with padding and margin but I could not fix the issue.
This is a screenshot of the problem: as you can see the icon are placed slightly higher:
This is part of the html, each button is more or less the same:
<div id="mainToolbar">
<button id="buttonPencil" data-tool="yes" data-type="draw" title="Use pencil" class="button" onclick="changeTool(0);">
<i class="material-icons">brush</i>
</button>
</div>
This is the css for the button:
.button {
margin: auto;
display: inline-block;
margin-top: 5px;
color: black;
border: 0px solid grey;
border-radius: 6px;
background-color: #EFEFEF;
text-align: center;
text-decoration: none;
cursor: pointer;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
z-index: 4;
vertical-align: middle;
}
.button {
width: 50px;
height: 40px;
}
.button:hover {
background-color: #aaaaaa !important;
color: white !important;
}
And finally the css for the div:
#mainToolbar {
position: absolute;
top: 0px;
left: 0px;
height: 520px;
width: 60px;
z-index: 10;
text-align: center;
}
How can I put the icon right in the middle of the button (both vertically and horizontally)? Thanks.
You can use absolute positioning along with translate to position the icon right in the middle. Be sure to add a position:relative on the button so that the icon is positioned w.r.t to the button.
.button {
margin: auto;
display: inline-block;
margin-top: 5px;
color: black;
border: 0px solid grey;
border-radius: 6px;
background-color: #EFEFEF;
text-align: center;
text-decoration: none;
cursor: pointer;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
z-index: 4;
vertical-align: middle;
}
.button {
width: 50px;
height: 40px;
position: relative;
}
.button:hover {
background-color: #aaaaaa !important;
color: white !important;
}
.button:active i{
/*for push effect on click*/
transform: translate(-45%, -45%);
}
.button i {
/*horizontal and vertical centering*/
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#mainToolbar {
position: absolute;
top: 0px;
left: 0px;
height: 520px;
width: 60px;
z-index: 10;
text-align: center;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<div id="mainToolbar">
<button id="buttonPencil" data-tool="yes" data-type="draw" title="Use pencil" class="button" onclick="changeTool(0);">
<i class="material-icons">brush</i>
</button>
</div>
To explain:
top:50% with a position: absolute will move the icon down 50% of the parent's height. A translateY with -50% will move the icon up by half its height so that its aligned right in the middle by its center. Similarly with horizontal centering.
Its Working Fine see snippet
.button {
margin: auto;
display: inline-block;
margin-top: 5px;
color: black;
border: 0px solid grey;
border-radius: 6px;
background-color: #EFEFEF;
text-align: center;
text-decoration: none;
cursor: pointer;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
z-index: 4;
vertical-align: middle;
}
.button {
width: 50px;
height: 40px;
}
.button:hover {
background-color: #aaaaaa !important;
color: white !important;
}
And finally the css for the div:
#mainToolbar {
position: absolute;
top: 0px;
left: 0px;
height: 520px;
width: 60px;
z-index: 10;
text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div id="mainToolbar">
<button id="buttonPencil" data-tool="yes" data-type="draw" title="Use pencil" class="button" onclick="changeTool(0);">
<i class="fa fa-leaf"></i>
</button>
</div>

CSS 3D effect banner

I am trying to figure out how to illustrate a banner that goes behind the body and continues in the background.
I want to achieve something like this:
But the difficult part is the wrap-around when it goes to the background (3D-effect).
This is what I got so far: https://jsfiddle.net/4v6xLtyf/
<body>
<div class="navbar background-banner">
</div>
<div class="body-content">
<div style="height:1000px" class="container content-block">
<h1 style="text-align: center">My Website</h1>
<div class="navbar navbar-inverse navbar-top navbar-custom-top">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a>Home</a></li>
<li><a>About Us</a></li>
<li><a>Login</a></li>
</ul>
</div>
</div>
<p>Content goes here</p>
</div>
</div>
</body>
You can play with :before, :after and border to do the trick, something close to what you need could be adding the following CSS rules:
.navbar-custom-top:before {
content: "";
background-color: transparent;
width: 30px;
height: 50px;
position: absolute;
border-left: 25px solid transparent;
border-top: 31px solid #bb5911;
top: 50px;
left:0;
}
.navbar-custom-top:after {
content: "";
background-color: transparent;
width: 30px;
height: 50px;
position: absolute;
border-right: 25px solid transparent;
border-top: 31px solid #bb5911;
top: 50px;
right: 0;
}
Working fiddle
Then play with the size, position and colors to match exactly what you need.
Update answer......
I made an example from #user2570380 reference link.
Just take a look my link_codpen .
New CSS with two new class ribbonoutline & ribbonul
/***********************/
.ribbonul:before, .ribbonul:after {
content: "";
position: absolute;
display: block;
border-style: solid;
border-color: #BB5911 transparent transparent transparent;
bottom: -1em;
}
.ribbonul:before {
left:0;
border-width: 1em 0 0 1em;
}
.ribbonul:after {
right: 0;
border-width: 1em 1em 0 0;
}
.ribbonoutline:after {
content: "";
position: absolute;
display: block;
background-image: linear-gradient(rgb(234, 115, 29), rgb(255, 168, 0)) !important;
height: 28px;
width: 100%;
margin-top: -10px;
left: 0;
z-index: -9999;
}
html,
body {
background-image: linear-gradient(rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7)) !important;
background-attachment: fixed;
font-family: Algerian;
}
/* Set padding to keep content from hitting the edges */
.body-content {
padding-bottom: 100px;
padding-left: 15px;
padding-right: 15px;
position:relative;
z-index:1
}
/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
max-width: 280px;
}
.content-block {
background-color: white;
border-radius: 5px;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
margin-top: 20px;
margin-bottom: 20px;
padding: 22px;
width: 70%;
margin: auto;
height: 500px;
}
.background-banner {
background-image: linear-gradient(rgb(234, 115, 29), rgb(255, 168, 0)) !important;
margin-top: 150px;
border-radius: 0px;
border: 0px;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
position: absolute;
width: 100%;
z-index: 0;
}
a {
color: black;
text-decoration: none;
}
a:hover,
a:focus {
color: white;
text-decoration: none;
}
.navbar-custom-top {
background-image: linear-gradient(rgb(234, 115, 29), rgb(255, 168, 0)) !important;
margin-top: 50px;
margin-left: -40px;
margin-right: -40px;
border-radius: 0px;
border: 0px;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.custom-container {
padding-right: 0px;
padding-left: 0px;
margin-right: auto;
margin-left: auto;
}
.navbar-fixed-top,
.navbar-fixed-bottom {
border-top-width: 0px;
border-bottom-width: 0px;
}
.navbar-header {
float: left;
width: 100%;
text-align: center;
}
ul.navbar-nav > li {
display: inline;
}
ul.navbar-nav {
float: none;
margin: 0 auto;
text-align: center;
display: block;
position: relative;
}
.content {
min-height: 1000px;
}
.navbar-inverse .navbar-nav > li > a {
color: black;
margin-left: 50px;
margin-right: 50px;
padding-top: 10px;
padding-bottom: 10px;
font-weight: bold;
font-size: 25px;
border-bottom: 2px solid transparent;
}
.navbar-inverse .navbar-nav > li > a:hover {
color: black;
border-bottom: 2px solid transparent;
border-bottom-color: #fff;
}
.navbar-inverse .navbar-nav > .active > a,
.navbar-inverse .navbar-nav > .active > a:hover,
.navbar-inverse .navbar-nav > .active > a:focus {
color: #000000;
background-color: transparent;
border-bottom: 2px solid transparent;
border-bottom-color: black;
}
/***********************/
/***********************/
/***********************/
.ribbonul:before, .ribbonul:after {
content: "";
position: absolute;
display: block;
border-style: solid;
border-color: #BB5911 transparent transparent transparent;
bottom: -1em;
}
.ribbonul:before {
left:0;
border-width: 1em 0 0 1em;
}
.ribbonul:after {
right: 0;
border-width: 1em 1em 0 0;
}
.ribbonoutline:after {
content: "";
position: absolute;
display: block;
background-image: linear-gradient(rgb(234, 115, 29), rgb(255, 168, 0)) !important;
height: 28px;
width: 100%;
margin-top: -10px;
left: 0;
z-index: -9999;
}
<div class="navbar background-banner">
</div>
<div class="body-content">
<div class="container content-block">
<h1 style="text-align: center">My Website</h1>
<div class="navbar navbar-inverse navbar-top navbar-custom-top">
<div class="navbar-collapse collapse ribbonoutline">
<ul class="nav navbar-nav ribbonul">
<li><a>Home</a></li>
<li><a>About Us</a></li>
<li><a>Login</a></li>
</ul>
</div>
</div>
<p>Content goes here</p>
</div>
</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>