in this code, the font size increases in proportion to the screen ratio
/*
#mixin fontSuperSize($number){
#media (min-aspect-ratio: 2/1) {
font-size: $number * 2vh;
}
#media (max-aspect-ratio: 2/1) {
font-size: $number * 1vw;
}
}*/
#media (min-aspect-ratio: 2 / 1) {
div {
font-size: 8vh; } }
#media (max-aspect-ratio: 2 / 1) {
div {
font-size: 4vw; } }
<div>1234567890987654321</div>
The length of the child elements is more than 100 vmin in total, and therefore the adjustment comes. I need to reduce the scale of the child elements so that the adjustment does not occur on the square screens.
How can I do the same as for text but for a div. That is what I have now...
How can I make it so that the div does not work out
<div class="main">
<div class="auth"></div>
<div class="table" ></div>
<div class="news" ></div>
</div>
<style>
.main {
width: 100vw;
height: 100vh;
}
.auth {
width: 60vmin;
height: 60vmin;
background: blue;
position: absolute;
left: 2%;
right : 2%;
}
.table {
width: 60vmin;
height: 20vmin;
background: green;
position: absolute;
right: 2%;
top: 2%;
}
.news {
width: 70vmin;
height: 20vmin;
background: gold;
position: absolute;
right: 2.5%;
bottom: 2.5%;
}
</style>
Related
What is the best way to do that?
If full screen then show "FULL SCREEN MEMBERSHIP"
If mobile or tablet size then show "Please use Full Screen" and hide textA
Thanks !!!
#media only screen and (min-width: 301px) {
html,body{
height: 100vh;
width: 100%;
background: #356aa0;
}
.fullScreen{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50% , -50%);
background: #fff;
width: 400px;
border-radius: 12px;
text-align: center;
}
p {
display:none
}
#media only screen and (max-width: 300px) {
body {
background-color: red;
}
p {
display:block
}
}
<div class="fullScreen">
FULL SCREEN MEMBERSHIP
</div>
<p id="mobile">Please use Full Screen</p>
Try this:
html,
body {
height: 100vh;
width: 100%;
background: #356aa0;
}
.fullScreen {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background: #fff;
width: 400px;
border-radius: 12px;
text-align: center;
}
p {
display: none
}
#media only screen and (max-width: 300px) {
p {
display: block !important;
}
.fullScreen{
display:none;
}
}
<div class="fullScreen">
FULL SCREEN MEMBERSHIP
</div>
<p id="mobile">Please use Full Screen</p>
I am trying to create a page with a slot machine and I have some issues when I am trying to make it responsive. At some point it gets cut off when going to smaller devices. Also I think that I made it a bit complicated , I hope you guys understand my mess of a code. thanks a lot
* {
margin: 0;
padding: 0;
border: 0 none;
box-sizing: border-box;
}
html,
body {
width: 100%;
height: 100%;
}
.background {
background: url("bg.jpg");
height: 500px;
padding: 270px 0;
height: 100%;
background-repeat: no-repeat;
width: 100%;
}
.all-parts {
margin: auto;
height: 300px;
width: 50%;
position: relative;
}
.slot-machine {
background: url("slot-machine.png");
background-repeat: no-repeat;
height: 500px;
width: 100%;
position: absolute;
}
.free-spins {
background: url("freespins-banner.png");
background-repeat: no-repeat;
height: 100px;
position: absolute;
top: 150px;
left: 370px;
z-index: 3;
width: 60%;
}
.click-to-spin {
background: url("diagonal-strip.png");
background-repeat: no-repeat;
position: absolute;
z-index: 3;
top: 450px;
width: 100%;
height: 130px;
background-size: cover;
}
.click-to-spin p {
text-align: center;
margin-top: 70px;
font-size: 40px;
color: rgb(247, 241, 198);
}
.first-slot img {
margin-top: -1180px;
margin-left: 215px;
width: 120px;
}
.second-slot img {
margin-top: -1180px;
margin-left: -10px;
width: 120px;
}
.third-slot img {
margin-top: -1180px;
margin-left: -10px;
width: 120px;
}
first-slot,
.second-slot,
.third-slot {
float: left;
}
.slot-machine-wrapper {
overflow: hidden;
height: 150px;
margin-top: 60px;
}
#media only screen and (max-width: 1400px) {
body {
background-color: red;
}
.all-parts {
width: 100%;
display: table;
}
.slot-machine {
width: 100%;
}
}
<div class="background">
<div class="all-parts">
<div class="slot-machine">
<div class="slot-machine-wrapper">
<div class="first-slot">
<img src="slot-strip.png">
</div>
<div class="second-slot">
<img src="slot-strip.png">
</div>
<div class="third-slot">
<img src="slot-strip.png">
</div>
</div>
</div>
<div class="free-spins">
</div>
</div>
<div class="click-to-spin">
<p>Click to spin!</p>
</div>
</div>
i will suggest you use css #media queries to break points, for example
// Small devices (landscape phones, 576px and up)
#media (min-width: 576px) {
.slot-machine {
background:url("slot-machine.png");
background-repeat: no-repeat;
height:200px;
width:70%;
position: absolute;
}
}
// Medium devices (tablets, 768px and up)
#media (min-width: 768px) {
.slot-machine {
background:url("slot-machine.png");
background-repeat: no-repeat;
height:250px;
width:80%;
position: absolute;
}
}
// Large devices (desktops, 992px and up)
#media (min-width: 992px) { ... }
// Extra large devices (large desktops, 1200px and up)
#media (min-width: 1200px) { ... }
just place the css value that will likely change accross devices in each #media queries above, also remember to have this in your meta tag
<meta name="viewport" content="width=device-width, initial-scale=1">
So I'm having a problem where some buttons in a seperate div are binding to a header I've absolute positioned the logo's and the intro section is a separate div.
Heres the html including buttons that aren't working
<div class="header">
<div class="logo-right">
<img src="/img/project-logo.png" alt="Hedonist Project" />
<img src="/img/drinks-logo.png" alt="Hedonist Drinks" />
</div>
<div class="logo">
<img src="/img/logo.png" alt="Hedonist Events" />
<h4>a creative drinks consultancy</h4>
</div>
</div>
<div class="intro">
<div class="container">
<div class="intro__text editable"><h3>Hedonist Events are an events agency
for bar staff, bar management, events production and pop-up bars.</h3>
<div class="intro__buttons">
<a class="btn" href="#contact">get in touch</a>
<a class="btn" target="_blank" rel="noopener" href="deck.html">see the event deck</a>
</div>
Heres the css
.logo {
display: flex;
position: absolute;
top: 5.3em;
left: 6.5em;
right: 0;
bottom: 0;
img {
height: 3.5em;
width: auto;
padding-right: 1.5em;
}
#media (max-width: 850px) {
display: block;
left: 4.3em;
}
}
.logo-right {
position: absolute;
top: 5.3em;
right: 12.5em;
bottom: 0;
img {
height: 3.5em;
width: auto;
padding-right: 1.5em;
}
#media (max-width: 1300px) {
right: 8em;
}
#media (max-width: 950px) {
display: none;
}
}
.header {
height: 20em;
width: 100%;
#media (max-width: 1000px) {
height: 10em;
}
}
When using absolute in this case the header as to be relative:. Also using absolute position and you want to align a tag left just use "left" no need for "right" unless you want it to fill the whole space of the relative container. Update your code with the below
.logo {
display: flex;
position: absolute;
top: 5.3em;
left: 6.5em;
img {
height: 3.5em;
width: auto;
padding-right: 1.5em;
}
#media (max-width: 850px) {
display: block;
left: 4.3em;
}
}
.logo-right {
position: absolute;
top: 5.3em;
right: 12.5em;
img {
height: 3.5em;
width: auto;
padding-right: 1.5em;
}
#media (max-width: 1300px) {
right: 8em;
}
#media (max-width: 950px) {
display: none;
}
}
.header {
height: 20em;
width: 100%;
position: relavtive;
#media (max-width: 1000px) {
height: 10em;
}
}
So I have two <div> next to each other and I want to make it so when you have little space (Phone for example) it puts the second <div> under the first one with some space. When you're on a 16:9 ratio computer it has them next to each other.
body {
background: #FFFFFF;
}
.box {
float: left;
margin: 10px;
padding: 25px;
max-width: 300px;
height: 300px;
border: 1px solid black;
}
div {
max-width: 2480px;
z-index: 2;
left: 0;
position: absolute;
width: 100%;
height: 50px;
top: 0px;
color: #2D2E32;
background: #2D2E32;
}
/*Box1*/
div2 {
position: absolute;
color: #2D2E32;
background: #2D2E32;
width: 700px;
height: 950px;
top: 700;
left: 200;
}
div3
/*Box2*/
{
position: absolute;
color: #2D2E32;
background: #2D2E32;
width: 700px;
height: 950px;
top: 700;
right: 10%;
}
img {
max-height: 800;
max-width: 2480;
z-index: 1;
width: 100%;
height: 63%;
left: 10%;
}
div4 {
max-height: 59%;
z-index: -1;
position: absolute;
width: 100%;
height: 59%;
top: 5%;
color: #17181A;
background: #17181A;
left: 0;
}
div5 {
max-width: 2480;
max-height: 25;
z-index: 2;
left: 0;
position: absolute;
width: 100%;
height: 25px;
color: #2D2E32;
background: #2D2E32;
}
<body>
<div id="page1">
<!--Task-->
<a id="Task" class="smooth"></a>
</div>
<div2 id="page2">
<!--Box1-->
<a id="Info1" class="smooth" class="box"></a>
</div2>
<div3>
<!--Box2-->
<a id="Info1" class="smooth" class="box"></a>
</div3>
</body>
CSS Media Queries will solve this problem by allowing you to create styles that will be conditionally applied based on a query that you specify. Here's an example:
/* Develop "mobile-first, meaning that your normal styles should reflect how you want
the content to look on a mobile device
div elements will normally appear on their own line, but let's add a little space between
the lines
*/
div { margin:1em; }
/* When the viewport is not bigger than 760px and it is rotated to be wide
put divs next to each other and only move them down when the full width
of the viewport is used up */
#media screen and (max-width:760px) and (orientation:landscape) {
div {
float:left;
margin:auto; /* reset margins back to normal */
}
}
<div>Some div content</div>
<div>Some div content</div>
I've been playing with this grid for a while, it's a two grid system in which i'm trying to add two different images. I've added the images with success. However, It's when i try to make two separate containers for the text i would like to place over the images everything goes wrong. Been trying to wrap my head around this for hours without results.
I did succeed to add text over the image with the one column. However, these two columns just won't let me.
What is the best way to solve this?
CSS
/* SECTIONS */
.section-ad {
clear: both;
padding: 0px;
margin:0;
}
/* COLUMN */
.col {
display: block;
float:left;
margin: 0% 0% 0% 1%;
}
.col:first-child { margin-left: 0; }
/* GROUP */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }
/* TWO GRID */
.span_2_of_2 {
width: 100%;
height: auto;
}
.span_1_of_2 {
width: 49.5%;
height: auto;
}
.span_2_of_2 img {
width: 100%;
height: auto;
}
.span_1_of_2 img {
width: 100%;
height: auto;
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
#media only screen and (max-width: 480px) {
.col {
margin: 0% 0 0% 0%;
}
}
#media only screen and (max-width: 480px) {
.span_2_of_2, .span_1_of_2 { width: 100%; }
}
HTML
<div class="section-ad group">
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-sale-large.jpg?11274335160121521292" />
</div>
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-plain-x450_ab05c8e5-7269-4d98-b510-8ba5127db9c4.jpg?13010707129353802904" />
</div>
</div>
Best Regards,
Robin.
You can place text over image following way.
Add span inside col div and add text inside. And give position:absolute and parent div to position:relative;. Then you can set it's position using left and right value.
.section-ad {
clear: both;
padding: 0px;
margin:0;
}
/* COLUMN */
.col {
display: block;
float:left;
margin: 0% 0% 0% 1%;
position: relative;
}
.col:first-child { margin-left: 0; }
/* GROUP */
.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }
/* TWO GRID */
.span_2_of_2 {
width: 100%;
height: auto;
}
.span_1_of_2 {
width: 49.5%;
height: auto;
}
.span_2_of_2 img {
width: 100%;
height: auto;
}
.span_1_of_2 img {
width: 100%;
height: auto;
}
span {
color: #000000;
font-size: 25px;
left: 50%;
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
/* GO FULL WIDTH AT LESS THAN 480 PIXELS */
#media only screen and (max-width: 480px) {
.col {
margin: 0% 0 0% 0%;
}
}
#media only screen and (max-width: 480px) {
.span_2_of_2, .span_1_of_2 { width: 100%; }
}
<div class="section-ad group">
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-sale-large.jpg?11274335160121521292" />
<span>Some text</span>
</div>
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-plain-x450_ab05c8e5-7269-4d98-b510-8ba5127db9c4.jpg?13010707129353802904" />
<span>Some text</span>
</div>
</div>
Thanks to all your replies.
Ketan - Altough your solution worked, it did not fit my needs.
However, thanks to your reply i managed to surpass my blackout. So i owe it too you anyway. Thanks!
This might now be the best way,
but this is how i did it.
CSS
CSS
/* TVĂ… KOLUMN ADVERT # 705x450 */
.span_1_container {
position: absolute;
top: 80%;
left: 25%;
z-index: 0;
padding: 0;
padding: 1.2em;
font-size: .5em;
text-align: center;
width: 45%;
}
.span_1_heading {
font-size: 20px;
line-height: 100px;
display:inline-block;
position: relative;
}
.span_2_container h2:before {
content: '';
border-top: 1px solid #383a4f;
position: absolute;
width: 25%;
left: 35%;
top: 50px;
}
.span_2_container {
position: absolute;
top: 25%;
left: 0%;
z-index: 0;
padding: 0;
padding: 1.2em;
font-size: .5em;
text-align: center;
width: 45%;
}
.span_2_container h2:after {
content: '';
border-bottom: 1px solid #383a4f;
position: absolute;
width: 25%;
left: 35%;
bottom: 50px;
padding-bottom: 20px;
}
<div class="section-ad group">
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-sale-large.jpg?5000542013708637763" />
<div class="span_1_container">
SHOP NOW</div>
</div>
<div class="col span_1_of_2">
<img src="https://cdn.shopify.com/s/files/1/0786/5107/files/main-plain-x450_ab05c8e5-7269-4d98-b510-8ba5127db9c4.jpg?13010707129353802904" />
<div class="span_2_container">
<h2 class="span_2_heading" style="font-weight: normal; color: #383a4f;">Pocketsquares</h2>
<p style="font-family: 'Lato'; font-size: 14px; color: #383a4f; line-height: 15px; padding-bottom: 20px;">Explore our premium pocketsquares.</p>
SHOP NOW</div>
</div>
</div>