Fluid scaling webpage not scaling as expected on Mobile - html

I have created a webpage that scales moderately well on the desktop, all the content is a percentage of the window height or width. I don't understand why the webpage isn't scaling to the size of the phone screen?
here is the website I've put on a hosting site so i can test it on my iPhone:
http://henryneilson.comli.com/Test/Index.html
HTML can be seen on that link
CSS for the important things is:
#charset "utf-8";
body {
overflow-x: hidden;
overflow-y: hidden;
text-align: center;
margin: 0px;
height: 100vh;
top: 0px;
}
#FSBG {
width: 177.77vh;
height: 100%;
min-width: 400px;
min-height: 225px;
margin-left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
#BackgroudDiv {
height: 100%;
text-align: center;
display: block;
background-color: #161619;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
width: 3000px;
position: fixed;
left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
z-index: -100;
}
.titletext {
color: #fff;
text-shadow: 0px 6px 8px rgba(0, 0, 0, 1);
font-size: 5vh;
text-align: center;
position: absolute;
top: -3.7vh;
left: 2%;
z-index: 10;
font-family: source-sans-pro;
font-style: normal;
font-weight: 100;
}
.titlebox {
width: 100%;
height: 7vh;
display: block;
background-color: #161619;
margin: auto;
top: 0px;
left 0px;
position: absolute;
z-index: 10;
}
Scaling the browser to the same resolution as an iPhone does not show what the iPhone shows (I want the iPhone to show what the desktop shows), am I missing something obvious?
Many thanks
H

Try adding this line in your HTML Head :
<meta name="viewport" content="width=device-width, initial-scale=1">

I found I was not using all three types of transform, so for chrome and Ie it was working yet the iPhone required I use all three:
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);

Related

Set offset shape as background on title

Basically I want to have a title and then behind it a square thats offset. I've tried to do this by positioning absolute my square and then putting behind the title but when I resize the page it goes off position.
I'm trying to achive the shape behind the title in the image example.
What I tried:
.shape {
position: absolute;
width: auto;
height: 30px;
min-height: 30px;
min-width: 30px;
border-radius: 10px;
background-color: rgb(25, 94, 76);
top: 43vh;
left: 28vw;
z-index: -1;
}
.center {
position: absolute;
left: 50%; /*Half width*/
top: 50%; /*Half height*/ translateY(-50%);
-webkit-transform: translateX(-50%)
translateY(-50%);
padding: 20px;
font-size: 1rem;
}
<div class="center">
Resize the page to see the shape go off center
</div>
<div class="shape"></div>
Here is a codepen: https://codepen.io/PhoenixBeatsYT/pen/XWjZLgB
Move the shape inside your text div then adjust to to the top and left.
Minor adjustments are probably necessary for perfect alignment.
.shape {
position: absolute;
width: auto;
height: 30px;
min-height: 30px;
min-width: 30px;
border-radius: 10px;
background-color: rgb(25, 94, 76);
z-index: -1;
top: 0;
left: 0;
}
.center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
padding: 20px;
font-size: 1rem;
}
<div class="center">
Resize the page to see the shape go off center
<div class="shape"></div>
</div>

Safari adding border around table cells regardless of border-collapse, padding: 0 etc

Despite having several settings to prevent this, Safari is displaying a visible border around table cells. I've attempted to adding padding: 0 and margin: 0 to all, but the issue doesn't seem to be padding related. I've tried various border settings on all related elements to prevent this, and yet it persists. It appears to only be an issue on iPhones/Safari. I've tested on a few different iPhone devices (I'm an android guy, so I was able to find two people in the office with different iPhones) and they each displayed the unwanted border. Here is a screenshot of the issue.
and here is the html:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Oswald'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style>
body {
background-color: #002D72;
font-family: 'OSWALD';
width: 100%;
max-width: 1280px;
height: 100%;
margin: 0 auto;
}
.mobile-wrap {
margin: 0 auto;
width: 100%;
}
.mobile-stations {
margin: 0 auto;
border-collapse: collapse;
border-spacing: 0;
}
.mobile-stations td {
color: GhostWhite;
width: 10vmax;
height: 10vmax;
font-size: min(1.6rem, 1.6vmax);
margin: 0 auto;
padding: 0 !important;
border: none;
background-color: red;
}
.mobile-stations td:nth-child(2) {
text-align: left;
width: auto !important;
}
.mobile-line-wrap {
position: relative;
height: 100%;
width: 100%;
margin: 0 auto;
}
.mobile-circle {
position: absolute;
background: GhostWhite;
border-radius: 50%;
width: 5vmax;
height: 5vmax;
margin: 0;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.mobile-circle2 {
position: absolute;
background: #002D72;
border-radius: 50%;
width: 4vmax;
height: 4vmax;
margin: 0;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.mobile-circle3 {
position: absolute;
background: GhostWhite;
border-radius: 50%;
width: 3vmax;
height: 3vmax;
margin: 0;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.mobile-circle4 {
position: absolute;
background: DarkRed;
border-radius: 50%;
width: 2vmax;
height: 2vmax;
margin: 0;
top: 50%;
left: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.mobile-line {
position: absolute;
width: .6vmax;
height: 100%;
background-color: GhostWhite;
margin-left: auto;
margin-right: auto;
text-align: center;
left: 0;
right: 0;
}
.mobile-line-top {
position: absolute;
width: .6vmax;
background-color: GhostWhite;
height: 50%;
margin-left: auto;
margin-right: auto;
text-align: center;
left: 0;
right: 0;
bottom: 0;
}
.mobile-line-bottom {
position: absolute;
width: .6vmax;
background-color: GhostWhite;
height: 50%;
margin-left: auto;
margin-right: auto;
text-align: center;
left: 0;
right: 0;
top: 0;
}
</style>
</head>
<body>
<div class="mobile-wrap">
<div class="mobile-locations">
<table class="mobile-stations">
<tr class="mobile-station-row">
<td><div class="mobile-line-wrap"><div class="mobile-line-top"></div><div class="mobile-circle"><div class="mobile-circle2"><div class="mobile-circle3"><div class="mobile-circle4"></div></div></div></div></div></td>
</tr>
<tr class="mobile-station-row">
<td><div class="mobile-line-wrap"><div class="mobile-line"></div><div class="mobile-circle"><div class="mobile-circle2"><div class="mobile-circle3"><div class="mobile-circle4"></div></div></div></div></div></td>
</tr>
<tr class="mobile-station-row">
<td><div class="mobile-line-wrap"><div class="mobile-line"></div><div class="mobile-circle"><div class="mobile-circle2"><div class="mobile-circle3"><div class="mobile-circle4"></div></div></div></div></div></td>
</tr>
<tr class="mobile-station-row">
<td><div class="mobile-line-wrap"><div class="mobile-line-bottom"></div><div class="mobile-circle"><div class="mobile-circle2"><div class="mobile-circle3"><div class="mobile-circle4"></div></div></div></div></div></td>
</tr>
</table>
</div>
</div>
</body>
</html>
rectangle; Image distortion occurs because the length and width are not equal. Current size (82x81)
.mobile-stations td {
color: GhostWhite;
width: 82px;
height: 82px;
font-size: min(1.6rem, 1.6vmax);
margin: 0 auto;
padding: 0 !important;
border: none;
background-color: red;
}

Fitting CSS background image to IOS

I could really use some help.
I have a 2000x1000 image png file I am using as my background for a website. It works great on a desktop. When viewing on my iphone, only the left 1/3 of the image is shown and it stacks two ontop of eachother. I have tried using background-size: auto and 100%, as well as background-attachment:scroll to no avail. I've created a proper aspect ratio image from the larger image and used media queries, but it still ends up super weird. You can find my current media in here which is supposed to detect if the resolution is < 415px to change the size to max, however this doesn't work. Ideally I would like the background to just center in the middle, maintain its aspect ratio and take up the full window height. Here is my CSS. Thanks.
*
{
margin: 0;
padding: 0;
}
.email
{
color:black;
font-size: 25px;
position: fixed;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
}
body
{
background: black;
background-image: url("images/Mountains.png");
}
.html
{
width: 100%;
height: 100%;
}
.github
{
position: fixed;
top: 37%;
left: 41%;
transform: translate(-50%, -50%);
}
#items
{
transition: margin-left .5s;
padding: 20px;
}
.link_in
{
position: fixed;
top: 37%;
left: 59%;
transform: translate(-50%, -50%);
}
.loc
{
color:black;
position: fixed;
top: 45%;
left: 50%;
transform: translate(-50%, -50%);
}
#media screen and (max-height: 450px)
{
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}
#media screen and (max-width: 415px)
{
body
{
background-color: black;
background-size: 100% 100%;
position: fixed;
top: 0;
left: 0;
bottom: 0;
/* Preserve aspect ratio */
min-width: 100%;
min-height: 100%;
}
}
#media screen and (max-width: 1100px)
{
.github {
position: fixed;
top: 37%;
left: 31%;
transform: translate(-50%, -50%);
}
.link_in
{
position: fixed;
top: 37%;
left: 69%;
transform: translate(-50%, -50%);
}
}
.sidenav
{
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden;
padding-top: 60px;
transition: 0.5s;
}
.sidenav a
{
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidenav a:hover
{
color: #f1f1f1;
}
.sidenav .close
{
font-size: 36px;
position: absolute;
top: 0;
right: 25px;
margin-left: 50px;
}
.thanks
{
color:black;
position: fixed;
top: 35%;
left: 50%;
transform: translate(-50%, -50%);
}
.under_construction
{
position: fixed;
top: 37%;
left: 50%;
transform: translate(-50%, -50%);
}
I think you're trying to keep the background image fixed and responsive. You can keep the size to cover, so it will resize the background image to cover the entire container, even if it has to stretch the image or cut a little bit off one of the edges. Then you can set the position to center, so if it stretches it will display the center part of the image. And keep the attachment to fixed, so when you scroll the background image is fixed.
background-size: cover;
background-position:center ;
background-attachment: fixed;

Chrome does not display image the same as other browsers

I'm trying to have an image gallery where pictures are displayed on the center of the screen, both vertically and horizontally; the posted fiddle is working fine on Edge, Internet Explorer and (Java Netbeans 8.02) Embedded Web Browser except on Google Chrome.
The problem in Chrome is as follows: if the picture's resolution is higher than the screen picture's edges will not be visible; the idea is to have the picture displayed without losing a pixel.
CSS:
.fullscreenContainer{
position: fixed;
overflow: hidden;
width: 100%;
height: 100%;
top: 0; right: 0; bottom: 0; left: 0;
background-color:rgba(0,0,0,0.55);
}
.imageGallery-container {
background-color: white;
z-index: 10000;
margin: auto;
position: relative;
text-align: center;
position: relative;
top: 50%;
transform: translateY(-50%);
-ms-transform: translateY(-50%);
/* IE 9 */
-webkit-transform: translateY(-50%);
/* Safari */
-moz-transform: translateY(-50%);
-o-transform: translateY(-50%);
}
.imageGallery-container > img {
margin: auto;
max-width: 100%;
max-height: 100%;
}
HTML
<div class="fullscreenContainer">
<div class="imageGallery-container">
<img src="http://cdn.wonderfulengineering.com/wp-content/uploads/2014/03/high-resolution-wallpapers-2.jpg">
</div>
</div>
https://jsfiddle.net/mL72yytk/2/
What's wrong with flexbox?
.fullscreenContainer{
position: fixed;
z-index: 10000;
width: 100vw;
height: 100vh;
top: 0;
left: 0;
background-color: white;
display: flex;
align-items: center;
justify-content: center;
}
.fullscreenContainer img {
display: block;
max-height: 100vh;
max-width: 100vw;
}
<div class="fullscreenContainer">
<img src="http://cdn.wonderfulengineering.com/wp-content/uploads/2014/03/high-resolution-wallpapers-2.jpg">
</div>
Don't forget to prefix.

Why is my FontAwesome content appearing off center as a background?

I am trying to set a FontAwesome icon as a "defualt thumbnail" for a list of articles. My problem is that the icon is appearing off center horizontally in my div. See the jsFiddle.
<div class="card-row-image fa fa-cutlery thumbnail-default">
<div class="card-row-label">Restaurants
</div>
<div class="card-row-price">Pennsylvania</div>
</div>
.thumbnail-default {
position: relative;
text-align: center;
border: 1px solid #547b97;
background: #e4e4e4;
}
.thumbnail-default:before {
position:absolute;
font-family: 'FontAwesome';
font-size: 72px;
color: #547b97;
text-align: center;
padding: 0px;
margin: 0px;
top: 50%;
transform: translateY(-50%);
}
.card-row-price {
background-color: #009f8b;
bottom: 0px;
color: #fff;
font-size: 13px;
left: 50%;
padding: 3px 15px;
position: absolute;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
white-space: nowrap;
z-index: 2;
}
.card-row-label {
background-color: #c6af5c;
color: #fff;
left: 50%;
font-size: 13px;
padding: 3px 15px;
position: absolute;
top: 0px;
transform: translateX(-50%);
-webkit-transform: translateX(-50%);
z-index: 2;
}
.card-row-image {
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
height: 200px;
position: relative;
width: 262px; }
Here is my current output:
Any ideas? Thanks for your time!
set these css codes to make it centered. This happens because on absolute positioned pseudo elements, if you do not specify where to be horizontally (you did not set left or right property), it will follow the text flow and would obey the text-align: center set on the parent.
.thumbnail-default:before { left: 50%; transform: translate(-50%, -50%); }
Working Fiddle