Print media acts differently in Firefox and Chrome - html

I am using #media print to generate a report. When I print it in chrome, it is fine, while in Firefox, the components are messed up in the positions. My code is provided as below in two different sections: the first one is the CSS styling and the next one the HTML code.
How can I write this code to work in Chrome and Firefox?
#media print {
.print-only {
display: block;
}
a[href]:after {
content: none !important;
}
object {
width: 160mm;
height: 120mm;
}
button, alert-danger, .no-print {
display: none !important;
}
.top-left-corner-print {
position: absolute;
top: 160px;
left: 50px;
font-size: 14px;
width: 200px;
}
.top-left-print {
position: absolute;
top: 160px;
left: 250px;
font-size: 14px;
width: 200px;
}
.top-print {
position: absolute;
top: 156px;
left: 450px;
font-size: 14px;
width: 200px;
}
.top-right-print {
position: absolute;
top: 160px;
left: 650px;
font-size: 14px;
width: 200px;
}
.top-left-print-second-row {
position: absolute;
top: 565px;
left: 60px;
width: 200px;
font-size: 20px;
}
.top-left-print-third-row {
position: absolute;
top: 950px;
left: 60px;
width: 200px;
font-size: 20px;
}
.print-audiogram-graph {
border: none !important;
position: absolute;
top: -170px;
left: 10px;
width: 95%;
height: 95%;
}
.print-abTest-graph {
border: none !important;
position: absolute;
top: 540px;
left: 50px;
width: 40%;
height: 40%;
}
.tympanometry-print {
border: none !important;
position: absolute;
top: 610px;
left: 420px;
}
.ipsi-reflex-print {
border: none !important;
position: absolute;
top: 780px;
left: 420px;
}
.contra-reflex-print {
border: none !important;
position: absolute;
top: 920px;
left: 420px;
}
.comment-print {
position: absolute;
top: 1010px;
left: 40px;
width: 360px;
word-break: break-all;
}
.no-border-print {
border: none;
}
aside#sidebar, header[role="banner"], footer, #comments, #respond {
display: none;
}
.page-header {
vertical-align: middle;
text-align: center;
border-bottom: none;
}
}
<div class="h2 page-header">Audiology Session</div>
<div class="alert alert-info top-buffer no-border-print" data-bind="with: metadata">
<div class="row">
<h4 class="col-md-6 top-left-corner-print" id="">
Client: <a data-bind="text: subjectName"></a>
</h4>
<h4 class="col-md-4 top-left-print">
Date: <span data-bind="text: date"></span>
</h4>
</div>
<div class="top-buffer"></div>
<div class="row">
<h4 class="col-md-6 top-right-print">
Clinician: <a data-bind="text: clinicianName"></a>
</h4>
<h4 class="col-md-4 no-print">
Clinic:
<span data-bind="css: { performedByBsh: performedByBsh }">
<span data-bind="text: clinic, css: { bshClinicUnset: bshClinicUnset }"></span>
</span>
</h4>
</div>
</div>
<div style="text-align:left; width:750px; max-width:100%">
<h3 class="no-print" style="margin-top:50px">Audiograms</h3>
<p class="top-print">Transducer: <span data-bind="text: transducer"></span></p>
<object class="print-audiogram-graph" id="audiogram-graph" type="image/svg+xml" data="~/Content/audiogram.svg" style="border:1px solid gray">
Your browser does not support svg objects.
</object>
</div>
<div style="text-align:left; width:450px; max-width:100%">
<h3 class="top-left-print-second-row" style="margin-top:50px">A/B Tests</h3>
<object class="print-abTest-graph" id="ab-test-graph" type="image/svg+xml" data="~/Content/abTest.svg" style="border:1px solid gray">
Your browser does not support svg objects.
</object>
</div>
<div>
<h3 class="no-print" style="margin-top:50px">Tympanometry</h3>
<div data-bind="with: $data.tympanometry()">
<div class="AudiologySession no-print" data-bind="visible: canShowTympanometryFields">
#Html.Partial("~/Views/Person/_TympanometryPartial.cshtml")
</div>
<div class="print-only">
#Html.Partial("~/Views/Person/_TympanometryPrintOnly.cshtml")
</div>
</div>
</div>
<div>
<h3 class="no-print" style="margin-top:50px">Reflexes</h3>
<div data-bind="with:reflexes">
<div class="AudiologySession no-print" data-bind="visible: canShowReflexFields">
#Html.Partial("~/Views/Person/_ReflexPartial.cshtml")
</div>
<div class="print-only">
#Html.Partial("~/Views/Person/_ReflexPrintOnly.cshtml")
</div>
</div>
</div>
<h3 class="top-left-print-third-row" style="margin-top:50px">Comments</h3>
<div class="comment-print" data-bind="with:metadata">
<div data-bind="visible: !editor.editing()">
<span data-bind="text: comment"></span>
</div>
<div data-bind="visible: editor.editing()">
<textarea maxlength="200" placeholder="Your comment…" type="text" data-bind="value: comment"></textarea>
</div>
</div>
Can anyone tell me what I am missing?

I could not find the best solution but using mm instead of px helped a lot to get a more close behavior in Firefox and Chrome and also using flex as follows in my css:
#media print {
.print-only {
display: block;
}
.wrapper-print {
display: grid;
grid-template-columns: 40% 10% 30% 20%;
grid-template-rows: 6mm 6mm 103mm auto auto;
}
.print-content-box {
grid-row: 4;
grid-column: 1/5;
display: flex;
flex-flow: column wrap;
max-height: 140mm;
}
.
.
.
and in the html:
<div class="print-content-box">
<div class="1">
.
.
.
</div>
<div class="2">
.
.
.
</div>
.
.
.
</div>

Related

Vertical Bar Chart - HTML and CSS

I am trying to do a vertical bar chart like this
But I am getting like this
At bottom of my vertical bar chart, both lines are attached together, I am trying to fix that.
I am trying to set that 0 line down but it's attached
And for example, bar height should get increase 25% if we give height: 25%; on inline CSS.
.barchart-Wrapper {
display: table;
position: relative;
margin: 20px 0;
height: 252px;
}
.barChart-Container {
display: table-cell;
width: 100%;
height: 100%;
padding-left: 15px;
}
.barchart {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
border-bottom: 3px solid tomato;
}
.barchart-Col {
position: relative;
vertical-align: bottom;
display: table-cell;
height: 100%;
}
.barchart-Col + .barchart-Col {
border-left: 4px solid transparent;
}
.barchart-Bar {
position: relative;
height: 0;
transition: height 0.5s 2s;
width: 66px;
margin: auto;
}
.barchart-Bar:after {
content: attr(attr-height);
color: white;
position: absolute;
text-align: center;
width: 100%;
}
.barchart-BarFooter {
position: absolute;
text-align: center;
height: 10%;
width: 100%;
}
.barchart-BarFooter h3 {
color: darkred;
}
.barchart-TimeCol {
position: absolute;
top: 0;
height: 100%;
width: 100%;
}
.barchart-Time {
height: 25%;
vertical-align: middle;
position: relative;
}
.barchart-Time:after {
border-bottom: 3px solid black;
content: "";
position: absolute;
width: 100%;
left: 0;
top: 0em;
}
.barchart-TimeText {
position: absolute;
top: -8px;
z-index: 1;
background: white;
padding-right: 5px;
color: #4d4d4d;
font-size: 15px;
font-family: 'Avenir Medium';
}
.html-bar {
background-color: deepskyblue;
}
.css-bar {
background-color: greenyellow;
}
.js-bar {
background-color: peachpuff;
}
.python-bar {
background-color: darkolivegreen;
}
.java-bar {
background-color: cornflowerblue;
}
<div class="barchart-Wrapper">
<div class="barchart-TimeCol">
<div class="barchart-Time">
<span class="barchart-TimeText">125</span>
</div>
<div class="barchart-Time">
<span class="barchart-TimeText">100</span>
</div>
<div class="barchart-Time">
<span class="barchart-TimeText">75</span>
</div>
<div class="barchart-Time">
<span class="barchart-TimeText">50</span>
</div>
<div class="barchart-Time">
<span class="barchart-TimeText">25</span>
</div>
</div>
<div class="barChart-Container">
<div class="barchart">
<div class="barchart-Col">
<div class="barchart-Bar html-bar" style="height: 75%;"></div>
<div class="barchart-BarFooter">
<h3>HTML</h3>
</div>
</div>
<div class="barchart-Col">
<div class="barchart-Bar css-bar" style="height: 75%;"></div>
<div class="barchart-BarFooter">
<h3>CSS</h3>
</div>
</div>
<div class="barchart-Col">
<div class="barchart-Bar js-bar" style="height: 75%;"></div>
<div class="barchart-BarFooter">
<h3>JS</h3>
</div>
</div>
<div class="barchart-Col">
<div class="barchart-Bar python-bar" style="height: 75%;"></div>
<div class="barchart-BarFooter">
<h3>PYTHON</h3>
</div>
</div>
<div class="barchart-Col">
<div class="barchart-Bar java-bar" style="height: 75%;"></div>
<div class="barchart-BarFooter">
<h3>JAVA</h3>
</div>
</div>
</div>
</div>
</div>
I guess doing a small change will help. Updated barchart-Time height to be 20%. Given 100% as 125. I believe this makes sense
.barchart-Wrapper {
display: table;
position: relative;
margin: 20px 0;
height: 252px;
}
.barChart-Container {
display: table-cell;
width: 100%;
height: 100%;
padding-left: 15px;
}
.barchart {
display: table;
table-layout: fixed;
height: 100%;
width: 100%;
border-bottom: 3px solid tomato;
}
.barchart-Col {
position: relative;
vertical-align: bottom;
display: table-cell;
height: 100%;
}
.barchart-Col+.barchart-Col {
border-left: 4px solid transparent;
}
.barchart-Bar {
position: relative;
height: 0;
transition: height 0.5s 2s;
width: 66px;
margin: auto;
}
.barchart-Bar:after {
content: attr(attr-height);
color: white;
position: absolute;
text-align: center;
width: 100%;
}
.barchart-BarFooter {
position: absolute;
text-align: center;
height: 10%;
width: 100%;
}
.barchart-BarFooter h3 {
color: darkred;
}
.barchart-TimeCol {
position: absolute;
top: 0;
height: 100%;
width: 100%;
}
.barchart-Time {
height: 20%;
vertical-align: middle;
position: relative;
}
.barchart-Time:after {
border-bottom: 3px solid black;
content: "";
position: absolute;
width: 100%;
left: 0;
top: 0em;
}
.barchart-TimeText {
position: absolute;
top: -8px;
z-index: 1;
background: white;
padding-right: 5px;
color: #4d4d4d;
font-size: 15px;
font-family: 'Avenir Medium';
}
.html-bar {
background-color: deepskyblue;
}
.css-bar {
background-color: greenyellow;
}
.js-bar {
background-color: peachpuff;
}
.python-bar {
background-color: darkolivegreen;
}
.java-bar {
background-color: cornflowerblue;
}
<div class="barchart-Wrapper">
<div class="barchart-TimeCol">
<div class="barchart-Time">
<span class="barchart-TimeText">125</span>
</div>
<div class="barchart-Time">
<span class="barchart-TimeText">100</span>
</div>
<div class="barchart-Time">
<span class="barchart-TimeText">75</span>
</div>
<div class="barchart-Time">
<span class="barchart-TimeText">50</span>
</div>
<div class="barchart-Time">
<span class="barchart-TimeText">25</span>
</div>
</div>
<div class="barChart-Container">
<div class="barchart">
<div class="barchart-Col">
<div class="barchart-Bar html-bar" style="height: 75%;"></div>
<div class="barchart-BarFooter">
<h3>HTML</h3>
</div>
</div>
<div class="barchart-Col">
<div class="barchart-Bar css-bar" style="height: 50%;"></div>
<div class="barchart-BarFooter">
<h3>CSS</h3>
</div>
</div>
<div class="barchart-Col">
<div class="barchart-Bar js-bar" style="height: 75%;"></div>
<div class="barchart-BarFooter">
<h3>JS</h3>
</div>
</div>
<div class="barchart-Col">
<div class="barchart-Bar python-bar" style="height: 25%;"></div>
<div class="barchart-BarFooter">
<h3>PYTHON</h3>
</div>
</div>
<div class="barchart-Col">
<div class="barchart-Bar java-bar" style="height: 100%;"></div>
<div class="barchart-BarFooter">
<h3>JAVA</h3>
</div>
</div>
</div>
</div>
</div>
Have you tried padding/ margin on the h3 element?
Try this:
h3 {
margin-top: 10px;
}
If this doesn't work there wil be a run around like this:
h3 {
position: relative;
top: 10px
}
If neither of these solutions work, feel free to command below.

make responsive a css + html design

I created a layout with 4 columns centered with margin and a triangle as an arrow-down with a star in the middle...
this is working nice in my computer:
But triangle and star are far away to be responsive, only way I achieved to position it correctly is with absolute position:
.triangle-down {
display: block;
position: absolute;
top: 0;
left: 318px;
width: 0;
height: 0;
border-left: 532px solid transparent;
border-right: 532px solid transparent;
border-top: 400px solid blue;
}
.star {
display: block;
position: absolute;
vertical-align: middle;
font-size: 250px;
text-align: center;
color: white;
top: -434px;
left: -109px;
}
How can I put the element in top of the others and make it responsive in the same way columns and it's margins?
NOTES:
layout is a countdown, but javascript is not important for the question.
You can find a functional (no JS) fiddle here
You can see actual result (with JS) here
I can use sass if necessary
How about this updated fiddle?
https://jsfiddle.net/ondrakoupil/0rtvcnon/11/
Basically, these are the changes:
use flexbox for column layout
sizes are measured using viewport-relative units (vw)
triangle is created as standard rectangular <div> and rotated via CSS - you have better control over its position and size
There are some CSS3 techniques used. For IE, you'll need to prefix them in CSS (use Autoprefixer). Other browsers should handle it "as it is".
html, body {
height: 100%;
margin: auto;
padding-left:1%;
background: yellow;
font: normal 16px 'Roboto', sans-serif;
}
.container {
margin: auto;
width: 80%;
height: 100%;
position: relative;
display: flex;
justify-content: space-between;
}
.bar {
background: red;
font-weight: 700;
text-align: center;
color: yellow;
width: 15%;
}
.init {
position:absolute;
bottom: 10px;
right: 20px;
background: yellow;
margin-left: 0px;
font-weight: 700;
text-align: right;
color: red;
}
a:link, a:visited {
color: red;
text-decoration: none;
}
::-moz-selection {
color: yellow;
background: red;
}
::selection {
color: yellow;
background: red;
}
p.numbers {
font-size: 8vw;
margin-top: 45vw;
margin-bottom: 20px;
}
p.meta, p.strings {
font-size: 2vw;
}
h1 {
font-size: 4.5em;
}
.triangle-down {
position: absolute;
top: 0;
left: 0;
right: 0;
pointer-events: none;
}
.triangle-color {
margin: auto;
width: calc(80vw / 1.4142);
height: calc(80vw / 1.4142); /* sqrt of 2 */
background-color: blue;
transform: translateY(calc(-1 * 80vw / 1.4142 / 2)) rotate(45deg);
}
.star {
position: absolute;
vertical-align: middle;
font-size: 15vw;
text-align: center;
color: white;
top: 5vw;
left: 0;
right: 0;
z-index: 1;
}
<body>
<div class="container">
<div class="triangle-down">
<div class="triangle-color"></div>
<div class="star">★</div>
</div>
<div class="bar">
<p id="d" class="numbers days">00</p>
<p class="strings">DIES</p>
</div>
<div class="bar">
<p id="h" class="numbers hours">00</p>
<p class="strings">HORES</p>
</div>
<div class="bar">
<p id="m" class="numbers minutes">00</p>
<p class="strings">MINUTS</p>
</div>
<div class="bar">
<p id="s" class="numbers seconds">00</p>
<p class="strings">SEGONS</p>
</div>
</div>
<div class="init">
ENTRA
</div>
</body>
Take a look at this. I was need to rewrite it from scratch, because you've got a lot of absolutes and they all calculated through js, as I understood. Hope, this will satisfy your requirements.
html, body {
margin: 0;
height: 100%;
}
.container {
width: 100%;
height: 100%;
background-color: yellow;
font: normal 16px 'Roboto', sans-serif;
position: relative;
}
.triangle-aspect-keeper {
width: 50%;
padding-bottom: 50%;
position: relative;
margin-left: auto;
margin-right: auto;
}
.triangle-container {
}
.triangle-down {
width: 100%;
height: 100%;
background-color: blue;
transform: rotate(45deg);
position: absolute;
top: -50%;
left: 0;
}
.star {
font-size: 1100%;
text-align: center;
color: white;
width: 100%;
line-height: 200%; /* control star vertical position */
position: absolute;
top: 0;
left: 0;
}
.bar-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
}
.bar-inner-container {
margin-left: auto;
margin-right: auto;
width: calc(50% * 1.41); /* sqrt(2) = 1.41. Length of the diagonal of the square*/
height: 100%;
display: flex;
justify-content: space-between;
}
.bar:first-child {
margin-left: 0;
}
.bar {
background-color: red;
height: 100%;
width: 15%;
color: yellow;
font-weight: 700;
}
p.numbers {
font-size: 5em;
margin-top: 350%;
}
p.meta, p.strings {
font-sie: 1.5em;
}
a:link, a:visited {
color: red;
text-decoration: none;
}
.init {
position: absolute;
bottom: 0;
right: 0;
padding: 10px;
font-weight: 700;
}
<body>
<div class="container">
<div class="bar-container">
<div class="bar-inner-container">
<div class="bar bar-first">
<p id="d" class="numbers days">00</p><br>
<p class="strings">DIES</p><br>
</div>
<div class="bar bar-second">
<p id="h" class="numbers hours">00</p><br>
<p class="strings">HORES</p><br>
</div>
<div class="bar bar-third">
<p id="m" class="numbers minutes">00</p><br>
<p class="strings">MINUTS</p><br>
</div>
<div class="bar bar-fourth">
<p id="s" class="numbers seconds">00</p><br>
<p class="strings">SEGONS</p><br>
</div>
</div>
</div>
<div class="triangle-aspect-keeper">
<div class="triangle-container">
<div class="triangle-down"></div>
<div class="star">★</div>
</div>
</div>
<div class="init">
ENTRA
</div>
</div>
</body>
#import url('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css');
html,
body {
background: yellow;
height: 100%;
}
.container {
position: relative;
height: 100%;
}
.row {
height: 100%;
}
.col-xs-3 {
height: 100%;
}
.col-xs-3,
.col-xs-12 {
padding: 0 6.25%;
}
.bar {
color: yellow;
background: red;
min-height: 100%;
padding-top: 333%;
}
.triangle-down {
position: absolute;
width: 100%;
height: auto;
z-index: 1;
}
.triangle-color {
margin-bottom: -30%;
}
.triangle-color * {
fill: blue
}
.star * {
fill: white
}
.numbers {
font-size: 5vw;
padding-bottom: 2vw;
}
.strings {
font-size: 1.5vw;
}
<div class="container text-center">
<div class="row triangle-down">
<div class="col-xs-12">
<svg class="triangle-color" viewBox="0 0 100 40">
<polygon points="0,0 100,0 50,40"/>
</svg>
<svg class="star" viewBox="0 0 1400 188">
<polygon points="700,0 640,188 790,68 610,68 760,188"/>
</svg>
</div>
</div>
<div class="row">
<div class="col-xs-3">
<div class="bar">
<div class="numbers">00</div>
<div class="strings">DIES</div>
</div>
</div>
<div class="col-xs-3">
<div class="bar">
<div class="numbers">00</div>
<div class="strings">HORES</div>
</div>
</div>
<div class="col-xs-3">
<div class="bar">
<div class="numbers">00</div>
<div class="strings">MINUTS</div>
</div>
</div>
<div class="col-xs-3">
<div class="bar">
<div class="numbers">00</div>
<div class="strings">SEGONS</div>
</div>
</div>
</div>
</div>
You can simply do this.
HTML:
<div class="parent">
<div class="triangle">
<div class="star">
...
</div>
</div>
</div>
CSS:
.parent {
width: xx%; /*Whatever percentage*/
height: yy%; /*Whatever percentage*/
margin: 0 auto;
position: relative;
}
.triangle {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.star {
font-size: xx%; /*some percentage (assuming star is a font icon)*/
position: absolute;
top: 15vh;
margin: 0 auto;
}

Buttons move around when resizing window

Everything on my page centers horizontally, including my buttons. However - when I resize my window, the buttons move vertically and off the page. Here is my jsfiddle: http://jsfiddle.net/rjord00r/utjhyckt/
.buttons {
text-align: center;
margin-top: 380px;
}
.buttons button {
padding: 8px;
border: none;
background-color: lightgrey;
font-weight: 500;
font-size: 13px;
position: relative;
text-align: center;
}
Thanks for your help!
This for you:
.searchBox{
position: fixed;
top: 50%;
left: 50%;
margin-top: -92px;
margin-left: -225px;
width: 450px;
text-align:center;
}
.logo {
width: 272px;
}
.search {
width: 450px;
height: 28px;
margin:15px 0px;
}
.search-bar{
position:relative;
}
#icon img {
position: absolute;
height: 28px;
width: 30px;
right: 0px;
top: 18px;
}
input:focus {
border-color: blue;
}
.buttons {
text-align: center;
}
.buttons button {
padding: 8px;
border: none;
background-color: lightgrey;
font-weight: 500;
font-size: 13px;
position: relative;
text-align: center;
}
<div class="searchBox">
<div class="centered">
<img class="logo" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">
</div>
<div class="search-bar">
<form>
<input type="text" class="search">
<div id="icon">
<img src="http://i.imgur.com/l5S4LZ2.png" />
</div>
</form>
</div>
<div class="buttons">
<button type="button">Google Search</button>
<button type="button">I'm Feeling Lucky</button>
</div>
</div>
There's a lot of unnecessary positioning, margins and elements in your example. To be able to achieve what I think you're after, I've had to change a few things.
See new EXAMPLE here.
Here's a summary of the changes : -
HTML
<div class="wrapper">
<div class="centered">
<img class="logo" src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />
<form class="search-bar">
<input type="text" class="search">
<div id="icon">
<img src="http://i.imgur.com/l5S4LZ2.png" />
</div>
</form>
<div class="buttons">
<button type="button">Google Search</button>
<button type="button">I'm Feeling Lucky</button>
</div>
</div>
</div>
CSS
.wrapper {
display: block;
position: relative;
width: 100%;
height: 750px;
}
.centered {
position: absolute;
top: 25%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
text-align: center;
}
.logo {
width: 272px;
}
.search {
width: 400px;
height: 28px;
}
.search-bar {
position: relative;
}
#icon img {
position: absolute;
height: 28px;
width: 30px;
right: 0px;
top: 3px;
}
.buttons {
text-align: center;
margin-top: 10px;
}
NOTE - I've removed anything from the example that I haven't changed.

HTML Line between circles

I am trying to achieve something like this:
But this is what I've managed to do.
Could you please help me to achieve desired result?
UPDATE:
Problem goes away if I remove bootstrap.css dependency. How can I make it work with bootstrap?
CodePen (add bootstrap.css in the settings to see an issue)
.time-slice {
display: flex;
align-items: stretch;
}
.time-slice > * {
padding: 20px;
}
.circle {
width: 16px;
height: 16px;
background: #ffffff;
border-radius: 32px;
display: block;
border: 2px solid #1A87B9;
}
.circle-wrap {
position: absolute;
}
.circle-wrap > .circle {
position: relative;
left: -30px;
}
.date-time {
flex-shrink: 0;
flex-basis: 60px;
}
.date,
.time {
max-width: 90px;
color: #999999;
font-size: 13px;
margin-top: 0;
margin-bottom: 10px;
}
.point-title {
border-left: 2px solid #1A87B9;
}
<div id="ticketDetails">
<h1>Details</h1>
<div class="time-slice row">
<div class="date-time">
<p class="time">10h 30min</p>
<p class="date"> </p>
</div>
<div class="circle-wrap">
<div class="circle"></div>
</div>
<div class="point-title">
<span>
<b>Amsterdam (Schiphol)</b>
</span>
</div>
</div>
<div class="time-slice row">
<div class="date-time">
<p class="date">Fri 28 Aug</p>
<p class="time">20:00</p>
</div>
<div class="circle-wrap">
<div class="circle"></div>
</div>
<div class="point-title">
<span>
<b>Manchester (MAN)</b>
</span>
</div>
</div>
</div>
The problem is in * {box-sizing: border-box} used by Bootstrap. Simply either set default box-sizing: content-box for .circle (fixed codepen demo) or take this property setting of the BS into account when you size/align your stuff.
change
.circle-wrap {
position: absolute;
> .circle {
position: relative;
left: -30px;
}
}
to
.circle-wrap {
position: absolute;
& > .circle {
position: relative;
left: -30px;
}
}

Centering a <div> inside a popup <div>

I'm having an issue figuring out how to center a <div> within a <div> that popped up after clicking a button.
Not my example, but similar. HTML:
<div class="popup">
<div class="options">
<div class="option">
<span id="1">1</span>
</div>
<div class="option">
<span id="2">2</span>
</div>
<div class="option">
<span id="3">3</span>
</div>
<div class="option">
<span id="4">4</span>
</div>
</div>
<p></p>
<div id="persona">
<span id="5">5</span>
</div>
</div>
CSS:
.popup
{
background-color: #e3ddd1;
position: absolute;
left: 10%;
top: 10%;
height: 400px;
width: 500px;
}
#persona
{
margin-left: auto;
margin-right: auto;
}
The overlay is just used to fade out the background, and then the popup appears on top of it.
The issue is in the #persona block, how do I get it so that <div id="persona"> is centered within the popup?
Try this CSS. Working Demo
.overlay
{
background-color: rgba(0, 0, 0, 0.8);
display: block;
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
}
.popup
{
background-color: #e3ddd1;
display: table;
position: absolute;
left: 50%;
top: 50%;
margin-left: -500px;
margin-top: -200px;
height: 400px;
width: 1000px;
}
#persona
{
display: table-cell;
margin-left: auto;
margin-right: auto;
text-align: center;
vertical-align: middle;
}