Element squeezed when width is narrow [duplicate] - html

This question already has an answer here:
Why is a flex item limited to parent size?
(1 answer)
Closed 3 years ago.
I've been asked to fix a problem that I don't understand. Can someone be kind enough to have a look at this fiddle?
When shrinking the width of the output pane so that the last question is forced to multi line, the accompanied span .checkmark is no longer round but elliptical.
body {
background-color: white;
color: black;
font-weight: 400;
font-family: telesans_text, Arial, Verdana, Helvetica, sans-serif;
margin: 0px;
}
.header-container {
padding: 1px;
text-align: left;
color: white;
}
.header-txt {
font-size: 15px;
margin: 5px 11px 4px 11px;
display: inline-block;
}
/* Format Question text */
.question-container {
flex: 1 1 auto;
margin: auto;
display: flex;
padding-bottom: 5px;
}
.question-text {
font-size: 17px;
font-weight: 600;
line-height: 22px;
text-align: left;
margin-bottom: 3px;
font-family: telesans_head, Verdana, Arial, Helvetica, sans-serif;
}
/* Format pages */
.question-page {
font-size: 12px;
margin: 10px 10px 10px 10px;
padding-bottom: 10px;
}
/* Question options format */
.option-container {
display: flex;
position: relative;
padding-left: 0px;
margin-bottom: 0px;
cursor: pointer;
font-size: 14px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.option-container input {
position: absolute;
opacity: 0;
}
.checkmark {
position: relative;
height: 15px;
width: 15px;
background-color: #D3D3D3;
border-radius: 50%;
margin-top: auto;
margin-bottom: auto;
margin-right: 15px;
}
.option-container:hover input~.checkmark {
background-color: #A9A9A9;
}
.option-container:hover {
background-color: #F8F8F8;
}
.option-container input:checked~.checkmark {
background-color: #dd2a30;
}
<div id="survey">
<div class="header-container">
<span class="header-txt">A question for you...</span>
</div>
<div id="question-body" class="modal-body">
<div id="q1" class="question-page">
<div class="question-container">
<span class="question-text">What is your relationship <br> with [brand]?</span>
</div>
<div class="option-container"><span class="checkmark"></span>Not a brand I'm familiar with
<input class="question-option" type="radio" name="q1" value="1">
</div>
<div class="option-container"><span class="checkmark"></span>I'm familiar, but not interested
<input class="question-option" type="radio" name="q1" value="2">
</div>
<div class="option-container"><span class="checkmark"></span>A brand I would consider purchasing
<input class="question-option" type="radio" name="q1" value="3">
</div>
<div class="option-container"><span class="checkmark"></span>My most preferred [product category]
<input class="question-option" type="radio" name="q1" value="4">
</div>
<div class="option-container"><span class="checkmark"></span>I plan to purchase [brand] when next buying [product category]
<input class="question-option" type="radio" name="q1" value="5">
</div>
</div>
</div>
</div>

That's because when the content is more that the space available, by default the flexbox items tries to shrink to the space available - add flex-shrink: 0 to checkmark - see demo below-
body {
background-color: white;
color: black;
font-weight: 400;
font-family: telesans_text, Arial, Verdana, Helvetica, sans-serif;
margin: 0px;
}
.header-container {
padding: 1px;
text-align: left;
color: white;
}
.header-txt {
font-size: 15px;
margin: 5px 11px 4px 11px;
display: inline-block;
}
/* Format Question text */
.question-container {
flex: 1 1 auto;
margin: auto;
display: flex;
padding-bottom: 5px;
}
.question-text {
font-size: 17px;
font-weight: 600;
line-height: 22px;
text-align: left;
margin-bottom: 3px;
font-family: telesans_head, Verdana, Arial, Helvetica, sans-serif;
}
/* Format pages */
.question-page {
font-size: 12px;
margin: 10px 10px 10px 10px;
padding-bottom: 10px;
}
/* Question options format */
.option-container {
display: flex;
position: relative;
padding-left: 0px;
margin-bottom: 0px;
cursor: pointer;
font-size: 14px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.option-container input {
position: absolute;
opacity: 0;
}
.checkmark {
flex-shrink: 0; /* ADDED */
position: relative;
height: 15px;
width: 15px;
background-color: #D3D3D3;
border-radius: 50%;
margin-top: auto;
margin-bottom: auto;
margin-right: 15px;
}
.option-container:hover input~.checkmark {
background-color: #A9A9A9;
}
.option-container:hover {
background-color: #F8F8F8;
}
.option-container input:checked~.checkmark {
background-color: #dd2a30;
}
<div id="survey">
<div class="header-container">
<span class="header-txt">A question for you...</span>
</div>
<div id="question-body" class="modal-body">
<div id="q1" class="question-page">
<div class="question-container">
<span class="question-text">What is your relationship <br> with [brand]?</span>
</div>
<div class="option-container"><span class="checkmark"></span>Not a brand I'm familiar with
<input class="question-option" type="radio" name="q1" value="1">
</div>
<div class="option-container"><span class="checkmark"></span>I'm familiar, but not interested
<input class="question-option" type="radio" name="q1" value="2">
</div>
<div class="option-container"><span class="checkmark"></span>A brand I would consider purchasing
<input class="question-option" type="radio" name="q1" value="3">
</div>
<div class="option-container"><span class="checkmark"></span>My most preferred [product category]
<input class="question-option" type="radio" name="q1" value="4">
</div>
<div class="option-container"><span class="checkmark"></span>I plan to purchase [brand] when next buying [product category]
<input class="question-option" type="radio" name="q1" value="5">
</div>
</div>
</div>
</div>

Related

Image not allowing neighboring div to align correctly

I'm designing an online clothing store, and on the product's page I want the product info (on the right) to align with the center of the image (on the left) while both of the divs are centered with the page. However, it seems that no matter what I do, the product info is always pushed down to the bottom corner of the image. It works when the image is removed completely, but unless that happens no formatting in CSS will affect the product-info div.
I've tried floating the elements to the left but that negates the text-align that keeps them centered, and any padding, margin, or dimension changes I make to the product-info only adds to the bottom of the div rather than shifting it up. There's probably something obvious that I'm overlooking, but I've been working on this problem for so long and just can't seem to find a fix.
Can someone please help me?
> Screenshot of how it looks <
* {
margin: 0px;
padding: 0px;
}
.product {
text-align: center;
}
.product-view {
top: 40px;
padding: 10px;
margin: 10px;
display: inline-block;
}
#product-image {
width: 400px;
height: 40%;
min-width: 40%;
min-height: 40%;
padding: 20px;
}
.product-info {
display: inline-block;
padding: 10px;
margin: 10px;
}
#product-name {
font-size: 25px;
text-transform: uppercase;
text-align: left;
}
#product-price {
font-size: 20px;
padding: 20px 0px;
text-align: left;
}
.product-info hr {
width: 278px;
opacity: 0.4;
}
#product-sizes {
padding: 5px;
text-align: center;
text-transform: uppercase;
width: fit-content;
}
#size-radio-btn {
display: inline-block;
width: 40px;
height: 40px;
text-align: center;
font-size: 15px;
border: 1px solid black;
margin: 5px 10px;
margin-left: 5px;
margin-right: 5px;
line-height: 40px;
color: black;
cursor: pointer;
}
#add-to-cart {
width: 278px;
height: 40px;
margin: 0 5px;
cursor: pointer;
background-color: black;
color: white;
text-transform: uppercase;
font-size: 15px;
float: left;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div class="content">
<div class="product">
<div class="product-view">
<img id="product-image" src="/Media/hoodieblack.png">
</div>
<div class="product-info">
<div id="product-name">
<h3>Hoodie - Black</h3>
</div>
<div id="product-price">
<p>$80.00</p>
</div>
<hr>
<div id="product-sizes">
<label for="size-select">Size</label>
<div id="size-select">
<input type="radio" name="size" value="s" hidden id="s-size">
<label for="s-size" id="size-radio-btn">S</label>
<input type="radio" name="size" value="m" hidden id="m-size">
<label for="m-size" id="size-radio-btn">M</label>
<input type="radio" name="size" value="l" hidden id="l-size">
<label for="l-size" id="size-radio-btn">L</label>
<input type="radio" name="size" value="xl" hidden id="xl-size">
<label for="xl-size" id="size-radio-btn">XL</label>
<input type="radio" name="size" value="xxl" hidden id="xxl-size">
<label for="xxl-size" id="size-radio-btn">XXL</label>
</div>
</div>
<button type="button" id="add-to-cart">Add to Cart</button>
</div>
</div>
</div>
</body>
</html>
Simply add display: flex; to the main parent, in this case, .product. Then you can use align-items: center; to get them in line with one another.
You can also add max-width: 100%; to the image so it resizes accordingly.
* {
margin: 0px;
padding: 0px;
}
.product {
text-align: center;
}
.product-view {
top: 40px;
padding: 10px;
margin: 10px;
display: inline-block;
}
#product-image {
width: 400px;
height: 40%;
min-width: 40%;
min-height: 40%;
padding: 20px;
}
.product-info {
display: inline-block;
padding: 10px;
margin: 10px;
}
#product-name {
font-size: 25px;
text-transform: uppercase;
text-align: left;
}
#product-price {
font-size: 20px;
padding: 20px 0px;
text-align: left;
}
.product-info hr {
width: 278px;
opacity: 0.4;
}
#product-sizes {
padding: 5px;
text-align: center;
text-transform: uppercase;
width: fit-content;
}
#size-radio-btn {
display: inline-block;
width: 40px;
height: 40px;
text-align: center;
font-size: 15px;
border: 1px solid black;
margin: 5px 10px;
margin-left: 5px;
margin-right: 5px;
line-height: 40px;
color: black;
cursor: pointer;
}
#add-to-cart {
width: 278px;
height: 40px;
margin: 0 5px;
cursor: pointer;
background-color: black;
color: white;
text-transform: uppercase;
font-size: 15px;
}
.product {
display: flex;
align-items: center;
justify-content: center;
}
#product-image {
max-width: 100%;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/style.css">
</head>
<body>
<div class="content">
<div class="product">
<div class="product-view">
<img id="product-image" src="https://dummyimage.com/800/000/fff">
</div>
<div class="product-info">
<div id="product-name">
<h3>Hoodie - Black</h3>
</div>
<div id="product-price">
<p>$80.00</p>
</div>
<hr>
<div id="product-sizes">
<label for="size-select">Size</label>
<div id="size-select">
<input type="radio" name="size" value="s" hidden id="s-size">
<label for="s-size" id="size-radio-btn">S</label>
<input type="radio" name="size" value="m" hidden id="m-size">
<label for="m-size" id="size-radio-btn">M</label>
<input type="radio" name="size" value="l" hidden id="l-size">
<label for="l-size" id="size-radio-btn">L</label>
<input type="radio" name="size" value="xl" hidden id="xl-size">
<label for="xl-size" id="size-radio-btn">XL</label>
<input type="radio" name="size" value="xxl" hidden id="xxl-size">
<label for="xxl-size" id="size-radio-btn">XXL</label>
</div>
</div>
<button type="button" id="add-to-cart">Add to Cart</button>
</div>
</div>
</div>
</body>
</html>

How to make 2 click-to-expand elements on the same line when expanding only the first element?

I'm using the following CSS to display two elements compactly.
.trigger,
/* to hide the checkbox and for more general use */
.gone,
.hidden {
display: none;
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
z-index: -999999;
top: -999999px;
margin: -1px;
padding: 0;
border: 0;
height: 1px;
width: 1px;
min-height: 0;
min-width: 0
}
label {
cursor: pointer
}
.fullverbtable {
display: none
}
.trigger:checked~.fullverbtable {
display: block
}
label {
font-family: 'Fira Sans', sans-serif;
font-size: 15px;
font-weight: normal;
font-style: normal;
color: white;
background-color: #ff4b54;
border-radius: 5px;
padding: 0px 5px;
text-decoration: none;
}
.verb {
display: inline;
}
<div class="verb">
<label for="aimer_larousse_ef_active_10">Conjugaison (voix active)</label>
<input class="trigger" id="aimer_larousse_ef_active_10" type="checkbox">
<div class="fullverbtable">
<link href="larousse_ef.css" rel="stylesheet" type="text/css">abcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
</div>
<div class="verb">
<label for="aimer_larousse_ef_passive10">Conjugaison (voix passive)</label>
<input class="trigger" id="aimer_larousse_ef_passive10" type="checkbox">
<div class="fullverbtable">
<link href="larousse_ef.css" rel="stylesheet" type="text/css">xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</div>
</div>
When expanding both 2 elements, the display is very fine.
I hope the result when expanding only the first element as
Could you please explain on how to do so?
I thought I understood your question if I'm right you want to create something like accordion by using checkboxes but the checkboxes can all be check and even the y share name that's I used the radio
to do so, and I don't want go on you with an invalid HTML that's why you'll find I edit too much but it's simple you'll find what you want
.trigger {
display: none;
}
label {
cursor: pointer
}
.fullverbtable_1,
.fullverbtable_2 {
display: none;
}
input[id="aimer_larousse_ef_active_10"]:checked~.fullverbtable_1,
input[id="aimer_larousse_ef_passive_10"]:checked~.fullverbtable_2 {
display: flex;
}
label {
font-family: 'Fira Sans', sans-serif;
font-size: 15px;
color: white;
background-color: #ff4b54;
border-radius: 5px;
padding: 0px 5px;
}
<div class="inputs">
<label for="aimer_larousse_ef_active_10">Conjugaison (voix active)</label>
<input type="radio" id="aimer_larousse_ef_active_10" name="trigger" class="trigger">
<label for="aimer_larousse_ef_passive_10">Conjugaison (voix passive)</label>
<input type="radio" id="aimer_larousse_ef_passive_10" name="trigger" class="trigger">
<div class="fullverbtable_1">abcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
<div class="fullverbtable_2">xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</div>
</div>
<div class="para">
</div>
If you want to expand all of them at the same time you can simply replace radio type to checkbox
.trigger {
display: none;
}
label {
cursor: pointer
}
.fullverbtable_1,
.fullverbtable_2 {
display: none;
}
input[id="aimer_larousse_ef_active_10"]:checked~.fullverbtable_1,
input[id="aimer_larousse_ef_passive_10"]:checked~.fullverbtable_2 {
display: flex;
}
label {
font-family: 'Fira Sans', sans-serif;
font-size: 15px;
color: white;
background-color: #ff4b54;
border-radius: 5px;
padding: 0px 5px;
}
<div class="inputs">
<label for="aimer_larousse_ef_active_10">Conjugaison (voix active)</label>
<input type="checkbox" id="aimer_larousse_ef_active_10" name="trigger" class="trigger">
<label for="aimer_larousse_ef_passive_10">Conjugaison (voix passive)</label>
<input type="checkbox" id="aimer_larousse_ef_passive_10" name="trigger" class="trigger">
<div class="fullverbtable_1">abcaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div>
<div class="fullverbtable_2">xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</div>
</div>
<div class="para">
</div>

How to make the textarea label display correctly [duplicate]

This question already has answers here:
What methods of ‘clearfix’ can I use?
(29 answers)
HTML radio buttons allowing multiple selections
(6 answers)
Closed 4 years ago.
I created a responsive form which changes to two columns when the screen size is resized. It mostly works the way I want it to.
However the label for textarea keeps showing incorrectly. I want it to display on a new line, but it keeps showing in the area of radio buttons.
There is also an issue with radio buttons where both can be selected at the same time. I have been trying to figure out what I did wrong but I can't find a solution.
Here is my code on jsfiddle.
/* CSS */
.myForm {
padding: 40px 20px;
}
.myForm h2,
.myForm p {
text-align: center;
padding: 0 10px;
}
.myForm h2 {
margin-bottom: 20px;
font-size: 20px;
font-weight: bold;
font-family: sans-serif;
}
.myForm p {
margin-bottom: 20px;
font-size: 12px;
}
.myForm label {
font-size: 14px;
}
form input {
border: 1px solid #a9a9a9;
border-radius: 3px;
height: 25px;
width: 96%;
margin: 10px 0;
font-size: 14px;
padding: 5px;
}
.label,
.radio input[type="radio"] {
display: inline;
float: left;
width: auto;
margin: 10px 0;
padding: 0 10px;
}
input[type="radio"],
input.radio {
vertical-align: text-top;
width: 13px;
height: 13px;
padding: 0;
margin: 0;
position: relative;
overflow: hidden;
top: -8px;
right: 5px;
}
.msg textarea {
width: 96%;
border: 1px solid #a9a9a9;
border-radius: 3px;
margin: 10px 0;
font-size: 14px;
padding: 5px;
}
form button {
background-color: #a9a9a9;
color: #fff;
width: 100%;
text-transform: uppercase;
padding: 10px;
border: none;
border-radius: 3px;
}
#media only screen and (min-width: 768px) {
/*Left form column*/
.left {
display: block;
float: left;
width: 48%;
}
/*Right form column*/
.right {
display: block;
float: right;
width: 48%;
}
.label,
.radio input[type="radio"] {
padding-right: 30px;
padding-left: 30px;
}
}
<!-- HTML -->
<form class="myForm">
<h2>Lorem ipsum</h2>
<p>text</p>
<div class="fields">
<label class="left">First Name
<input type="text" name="other"></label>
<label class="right">Last Name
<input type="text" name="other"></label>
<label class="left">text
<input type="text" name="other"></label>
<label class="right">text
<input type="text" name="other"></label>
<label class="left">text
<input type="text" name="other"></label>
<label class="right">text
<input type="text" name="other"></label>
<label class="left">text
<input type="text" name="other"></label>
<div class="radio right">
<label>Some text</label><br>
<label class="label">
<input type="radio" name="phone" value="phone">Phone</label>
<label class="label close">
<input type="radio" name="email" value="email">Email</label>
</div>
<div class="msg">
<label>Message</label>
<textarea rows="5"></textarea>
</div>
</div>
<button type="button" name="button">Send</button>
</form>
this should help:
.msg{
clear:both;
}
To fix the two problems you describe:
Your radio buttons need to have the same name field to be in the same group. If you set name="contact" for both, then they'll no longer be selectable at the same time.
You should remove float: left; from your CSS rules for .radio input[type="radio"]. This is taking precedence over the display: block; of the .msg div and causing them to be displayed on the same line.

Making input inside div always scale in one line

I would like to scale my input fields better.
When browser is maximized they look like this:
On smaller screens they look like this, the input fields goes to the bottom while it should be on the right:
My code:
.table-body {
width: 100%;
max-width: 952px;
border-spacing: 0px;
border-left: 1px solid #e4e4e4;
border-right: 1px solid #e4e4e4;
}
.table-body div {
padding-top: 3px;
padding-bottom: 3px;
}
.table-field1 {
text-align: center;
float: left;
padding-left: 11px;
padding-right: 11px;
}
.table-field2 {
font-size: 15px;
font-family: 'Roboto', sans-serif;
font-weight: 400;
color: #8f268d;
float: left;
margin-top: -2px;
}
.table-field3 {
color: #323232;
display: inline;
padding-left: 10px;
}
.table-field3 input {
border: 1px solid #e4e4e4;
width: 95%;
max-width: 844px;
color: #333333;
font-family: 'Roboto', sans-serif;
font-weight: 400;
font-size: 15px;
padding-top: 3px;
border-radius: 7px;
padding-left: 4px;
behavior: url(/panel/css/pie/pie.php);
}
<div class="table-body">
<div class="table-header">
<div class="left">
<input type="checkbox" name="usun_wszystkie" id="checkbox_all" class="css-checkbox" onchange="checkAll('checkbox[')">
<label for="checkbox_all" class="css-label"> Zaznacz wszystkie</label>
</div>
</div>
<div class="tabela_0">
<div class="table-field1">
<input type="checkbox" name="usun[438]" id="checkbox[438]" class="css-checkbox">
<label for="checkbox[438]" class="css-label"></label>
<input type="hidden" name="tag[438]" value="test.com">
</div>
<div class="table-field2">
<div>USUŃ</div>
</div>
<div class="table-field3">
<input type="text" name="entry" value="test.com">
</div>
</div>
</div>
<div class="table-end"></div>
If you can use flexbox to support your project, then try this:
.table-body {
width: 100%;
max-width: 952px;
border-spacing: 0px;
border-left: 1px solid #e4e4e4;
border-right: 1px solid #e4e4e4;
}
.tabela_0 {
display:flex;
}
.table-body div {
padding-top: 3px;
padding-bottom: 3px;
}
.table-field1 {
text-align: center;
padding-left: 11px;
padding-right: 11px;
}
.table-field2 {
font-size: 15px;
font-family: 'Roboto', sans-serif;
font-weight: 400;
color: #8f268d;
margin-top: -2px;
}
.table-field3 {
color: #323232;
padding-left: 10px;
flex-grow:1;
}
.table-field3 input {
border: 1px solid #e4e4e4;
width: 95%;
max-width: 844px;
color: #333333;
font-family: 'Roboto', sans-serif;
font-weight: 400;
font-size: 15px;
padding-top: 3px;
border-radius: 7px;
padding-left: 4px;
behavior: url(/panel/css/pie/pie.php);
}
<div class="table-body">
<div class="table-header">
<div class="left">
<input type="checkbox" name="usun_wszystkie" id="checkbox_all" class="css-checkbox" onchange="checkAll('checkbox[')">
<label for="checkbox_all" class="css-label"> Zaznacz wszystkie</label>
</div>
</div>
<div class="tabela_0">
<div class="table-field1">
<input type="checkbox" name="usun[438]" id="checkbox[438]" class="css-checkbox">
<label for="checkbox[438]" class="css-label"></label>
<input type="hidden" name="tag[438]" value="test.com">
</div>
<div class="table-field2">
<div>USUŃ</div>
</div>
<div class="table-field3">
<input type="text" name="entry" value="test.com">
</div>
</div>
</div>
<div class="table-end"></div>
Get the Fiddle: https://jsfiddle.net/z1o0fp1n/
I used tables:
<table><tr><td>
<div class="table-field2">
<div>USUŃ</div>
</div>
</td><td>
<div class="table-field3">
<input type="text" name="entry" value="test.com">
</div>
</td></tr>
</table>
Also you may use float:
<div class="table-field3" style='float:left;display:block'>
<input type="text" name="entry" value="test.com">
</div>
flexbox?
.table-body {
width: 100%;
max-width: 952px;
border-spacing: 0;
border-left: 1px solid #e4e4e4;
border-right: 1px solid #e4e4e4;
}
.table-body div {
padding: 3px;
}
.table-field2 {
font-size: 15px;
font-family: Roboto,sans-serif;
font-weight: 400;
color: #8f268d;
}
.table-field3 input {
border: 1px solid #e4e4e4;
color: #333;
font-family: Roboto,sans-serif;
font-weight: 400;
font-size: 15px;
padding-top: 3px;
border-radius: 7px;
padding-left: 4px;
behavior: url(/panel/css/pie/pie.php);
width: 95%;
}
.tabela_0 {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
padding: 3px;
}
.table-field3 {
width: 100%;
}
<div class="table-body">
<div class="table-header">
<div class="left"> <input type="checkbox" name="usun_wszystkie" id="checkbox_all" class="css-checkbox" onchange="checkAll('checkbox[')"><label for="checkbox_all" class="css-label"> Zaznacz wszystkie</label></div>
</div>
<div class="tabela_0"><div class="table-field1"><input type="checkbox" name="usun[438]" id="checkbox[438]" class="css-checkbox"><label for="checkbox[438]" class="css-label"></label><input type="hidden" name="tag[438]" value="test.com"></div><div class="table-field2"><div>USUŃ</div></div><div class="table-field3"><input type="text" name="entry" value="test.com"></div></div>
</div>

Creating Quiz: Why is it not working in Safari

The Quiz is perfectly showing in firefox and Chrome, just Safari seems to have some issues. It instantly shows the last test instead of the first like chrome and firefox are doing. What am I doing wrong. (I am using Safari Version 8.0.2 (10600.2.5)).
body {
font-size: 100%;
background: white;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, sans-serif;
font-weight: 300; }
input[type=radio],
input[type=checkbox] {
font-size: 0.8em;
position: relative;
display: inline-block;
vertical-align: middle;
border: 0.1em solid #bbbbbb;
background: none;
padding: 0.2em;
margin: 0 0.2em;
font-family: Consolas, "Courier New", monospace;
width: 1em;
height: 1em;
box-sizing: border-box;
-webkit-appearance: none; }
input[type=radio]:focus,
input[type=checkbox]:focus {
outline: 0;
border-color: #335599; }
input[type=radio] {
border-radius: 100%;
background-clip: content-box; }
input[type=radio]:checked {
background-color: #44aacc; }
h1 {
font-size: 2em;
margin: 1em auto;
text-align: center; }
.test {
position: absolute;
top: 25%;
bottom: 25%;
right: 25%;
left: 25%;
background: white; }
.test a {
display: block;
text-align: center;
padding: 0.5em 1em;
border-radius: 3px;
text-decoration: none;
background: #666666;
color: white; }
.test a:hover {
background: #4d4d4d; }
.test .question {
font-size: 1.3em;
margin: 0.5em 0;
border-bottom: 2px dashed #666666; }
.test .answer {
display: inline-block;
padding: 0.5em 1em;
cursor: pointer;
border-bottom: 4px solid white; }
.test .answer:hover {
border-color: #bbbbbb; }
.test .test {
transform: translate3d(150%, 0, 0);
transition: transform 100ms;
top: 0;
bottom: 0;
right: 0;
left: 0; }
.test .false:checked + .answer {
border-color: #dd4411; }
.test .true:checked ~ .test {
transform: translate3d(0, 0, 0); }
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="quiz_test.css" type="text/css">
<meta>
<title>test</title>
</head>
<body>
<h1>A simple Quiz in pure CSS</h1>
<div class="test">
<h3 class="question">1 + 2 = ?</h3>
<input type="radio" name="1" id="1-1" class="false"> <label for="1-1" class="answer">12</label><br>
<input type="radio" name="1" id="1-2" class="true"> <label for="1-2" class="answer">3</label>
<div class="test">
<h3 class="question">red - green, orange - blue, yellow - ?</h3>
<input type="radio" name="2" id="2-1" class="false"> <label for="2-1" class="answer">magenta</label><br>
<input type="radio" name="2" id="2-2" class="true"> <label for="2-2" class="answer">purple</label><br>
<input type="radio" name="2" id="2-3" class="false"> <label for="2-3" class="answer">cyan</label>
<div class="test">
<h3 class="question">name the fish!</h3>
<input type="radio" name="3" id="3-1" class="true"> <label for="3-1" class="answer">shark</label><br>
<input type="radio" name="3" id="3-2" class="false"> <label for="3-2" class="answer">dolphin</label><br>
<input type="radio" name="3" id="3-3" class="false"> <label for="3-3" class="answer">whale</label><br>
<input type="radio" name="3" id="3-4" class="false"> <label for="3-4" class="answer">all of the above</label>
<div class="test">
<h1>YOU WIN!!!</h1>
play again
</div>
</div>
</div>
</div>
</body>
</html>
The Problem is that webkit doesnt understand the transition and transform attributes without vendor prefixes. Copy every line of transition and transform and replace the duplicate with -webkit-transision and -webkit- transform.
body {
font-size: 100%;
background: white;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, sans-serif;
font-weight: 300; }
input[type=radio],
input[type=checkbox] {
font-size: 0.8em;
position: relative;
display: inline-block;
vertical-align: middle;
border: 0.1em solid #bbbbbb;
background: none;
padding: 0.2em;
margin: 0 0.2em;
font-family: Consolas, "Courier New", monospace;
width: 1em;
height: 1em;
box-sizing: border-box;
-webkit-appearance: none; }
input[type=radio]:focus,
input[type=checkbox]:focus {
outline: 0;
border-color: #335599; }
input[type=radio] {
border-radius: 100%;
background-clip: content-box; }
input[type=radio]:checked {
background-color: #44aacc; }
h1 {
font-size: 2em;
margin: 1em auto;
text-align: center; }
.test {
position: absolute;
top: 25%;
bottom: 25%;
right: 25%;
left: 25%;
background: white; }
.test a {
display: block;
text-align: center;
padding: 0.5em 1em;
border-radius: 3px;
text-decoration: none;
background: #666666;
color: white; }
.test a:hover {
background: #4d4d4d; }
.test .question {
font-size: 1.3em;
margin: 0.5em 0;
border-bottom: 2px dashed #666666; }
.test .answer {
display: inline-block;
padding: 0.5em 1em;
cursor: pointer;
border-bottom: 4px solid white; }
.test .answer:hover {
border-color: #bbbbbb; }
.test .test {
transform: translate3d(150%, 0, 0);
transition: transform 100ms;
-webkit-transform: translate3d(150%, 0, 0);
-webkit-transition: transform 100ms;
top: 0;
bottom: 0;
right: 0;
left: 0; }
.test .false:checked + .answer {
border-color: #dd4411; }
.test .true:checked ~ .test {
transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="quiz_test.css" type="text/css">
<meta>
<title>test</title>
</head>
<body>
<h1>A simple Quiz in pure CSS</h1>
<div class="test">
<h3 class="question">1 + 2 = ?</h3>
<input type="radio" name="1" id="1-1" class="false"> <label for="1-1" class="answer">12</label><br>
<input type="radio" name="1" id="1-2" class="true"> <label for="1-2" class="answer">3</label>
<div class="test">
<h3 class="question">red - green, orange - blue, yellow - ?</h3>
<input type="radio" name="2" id="2-1" class="false"> <label for="2-1" class="answer">magenta</label><br>
<input type="radio" name="2" id="2-2" class="true"> <label for="2-2" class="answer">purple</label><br>
<input type="radio" name="2" id="2-3" class="false"> <label for="2-3" class="answer">cyan</label>
<div class="test">
<h3 class="question">name the fish!</h3>
<input type="radio" name="3" id="3-1" class="true"> <label for="3-1" class="answer">shark</label><br>
<input type="radio" name="3" id="3-2" class="false"> <label for="3-2" class="answer">dolphin</label><br>
<input type="radio" name="3" id="3-3" class="false"> <label for="3-3" class="answer">whale</label><br>
<input type="radio" name="3" id="3-4" class="false"> <label for="3-4" class="answer">all of the above</label>
<div class="test">
<h1>YOU WIN!!!</h1>
play again
</div>
</div>
</div>
</div>
</body>
</html>
P.S. The snippet above doesn't run correctly in the preview box because some of stackoverflows css is interfering. It does however run correctly in the full page preview.