Chrome does not display image the same as other browsers - html

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.

Related

How to make video background cover the entire page

I have created a video background for my website but I am trying to make it cover the entire page.
My HTML:
<header>
<video loop muted autoplay playsinline poster="">
<source src="https://www.gordonmac.com/wp-content/uploads/storm-1.mp4" type="video/mp4">
<source src="http://freshsauce.test/video/FS Website-FINAL-PRORES.mov" type="video/mov">
</video>
<div class="banner">
<div class="banner-text">
Header Text Here
</div>
</div>
</header>
<p>yoooooo</p>
<p>yoooooo</p>
<p>yoooooo</p>
<p>yoooooo</p>
<p>yoooooo</p>
<p>yoooooo</p>
My CSS:
body{
margin:0;
}
header {
position: relative;
height: 100vh;
min-height: 100%;
width: 100%;
background-size: cover !important;
-webkit-background-size: cover !important;
text-align: center;
overflow: hidden;
z-index:-99;
}
video {
position: absolute;
top: 50%;
left: 50%;
z-index: -100;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
As you can see the <p>yoooooo</p> have a white background. The codepen is https://codepen.io/mrsalami/pen/wjmgze
Use css rule position:fixed; instead of position:absolute; for video tag
video {
position: fixed;
top: 50%;
left: 50%;
z-index: -100;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
I had a play with your CSS and added a few things. I normally remove all margin/padding from all elements at the top of my CSS file.
I then changed your video position from relative to absolute, meaning that nothing will affect it.
I also removed the !important tags. I would recommend trying to avoid these at all costs, unless absolutely necessary. Even then, avoid them at all costs.
* {
padding: 0px;
margin: 0;
}
body{
margin:0;
}
header {
position: absolute;
height: 100vh;
min-height: 100%;
width: 100%;
background-size: cover;
-webkit-background-size: cover;
text-align: center;
overflow: hidden;
z-index:-99;
}
video {
position: absolute;
top: 50%;
left: 50%;
z-index: -100;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
header:before {
content: '';
display: inline-block;
vertical-align: middle;
height: 100%;
}
header .banner {
display: inline-block;
vertical-align: center;
margin: 0 auto;
width: 85%;
padding-bottom: 30px;
text-align: center;
font:24px 'opensans-bold', sans-serif;
font-weight: bold;
}
header .banner-text {
color: #f5f5f5;
width: 100%;
}
You can do some thing like this. give position:fixed to video. it cover and set top, right, bottom, left to 0
https://codepen.io/arpanpatel/pen/rvdjGR
video {
position: fixed;
top: 0;
left: 0;
right:0;
bottom:0;
z-index: -100;
width: 100%;
}

How to create not clickable area around object?

It have to be not clickable area around this circle, how do I do that?
.circ {
position: absolute;
left: 50%;
top: 50%;
width: 400px;
height: 400px;
border-radius: 50%;
background: red;
overflow: hidden;
transform: translate(-50%, -50%);
}
.circ .sub-1,
.circ .sub-2 {
position: absolute;
width: 200px;
height: 200px;
background: green;
}
.circ .sub-1 a,
.circ .sub-2 a {
position: relative;
display: block;
width: 100%;
overflow: hidden;
height: 100%;
background: yellow;
}
.sub-2 {
bottom: 0;
right: 0;
}
<div class="circ">
<div class="sub-1">
</div>
<div class="sub-2">
</div>
</div>
Updated
It should work as is, tested in Edge and Firefox and both work, though Chrome (and maybe other WebKit based browsers too) had an issue earlier with not clipping border radius, and in your case they appear still does.
Here is a workaround, a simplified version of yours that does work, rotated 30 degrees.
The trick to make it work on Chrome (assume all WebKit based browsers) is:
to not use position on the div circ and anchors a
move the 2:nd anchor using margin instead of position
.wrap {
position: absolute;
left: 50%;
width: 400px;
height: 400px;
transform: translateX(-50%) rotate(30deg);
}
.circ {
width: 100%;
height: 100%;
border-radius: 50%;
background: red;
overflow: hidden;
}
.circ a {
display: block;
width: 50%;
height: 50%;
background: yellow;
}
.circ a + a {
margin-left: 50%;
}
<div class="wrap">
<div class="circ">
</div>
</div>

Highlight section without opacity

I have one issue in current project. I am applying background image in one div and also set opacity over it using :after.. Inside it, I have taken one another div which has border & content but I need to highlight middle section without opacity using same background image.
Sample Screenshot
.first_resorts_list_right { float: left; width: 434px; overflow: hidden; height: 477px; background-size: cover!important; background: no-repeat; padding: 70px; position: relative; background-image: url(http://s17.postimg.org/fa4ru3hm7/test.jpg); }
.resort-info { border: 10px solid #fff; padding: 20px; text-align: center; color: #000; font-size: 40px; }
.bannerimage2 { display: none; }
.expose { position: relative; z-index: 99999; }
.overlay-img { background: rgba(255,255,255,0.3); width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 99998; }
<div class="first_resorts_list_right">
<div class="resort-info expose">Content</div>
<div class="overlay-img"></div>
</div>
I made an alternative version, with divs wraping divs (plus sharing the same background values) instead of use :after
body {
width:100%;
height: 100vh;
margin: 0px;
font-family: arial, sans-serif;
}
#container {
width:100%;
height:100%;
position: relative;
}
#big {
top:0;
left:0;
width:100%;
height: 100%;
background-image: url("http://i.imgur.com/wvIxNg1.jpg");
background-size: 100vw 100vh;
background-repeat: no-repeat;
background-position: center;
position: relative;
-webkit-filter: blur(5px); /* Chrome, Safari, Opera */
filter: blur(5px);
}
#small {
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
width: 70%;
height: 70%;
outline: 4px solid white;
left: 0;
right: 0;
margin: auto;
background-image: url("http://i.imgur.com/wvIxNg1.jpg");
background-size: 100vw 100vh;
background-position: center;
background-repeat: no-repeat;
text-align: center;
color: white;
-webkit-filter: contrast(120%); /* Chrome, Safari, Opera */
filter: contrast(120%);
}
#white {
width:100%;
height: 100%;
background-color: white;
opacity: 0.1;
}
h1 {
font-weight: 100;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
left: 0;
right: 0;
margin: auto;
letter-spacing:8px;
}
<div id=container>
<div id=big>
<div id=white></div>
</div>
<div id=small><h1>FOCUS</h1></div>
</div>

Fluid scaling webpage not scaling as expected on Mobile

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%);

Center vertically and horizontally and overlap divs in css

I want to overlap two divs and then center them vertically and horizontally.
I am able to overlap the divs and center them vertically, BUT horizontal centering is not working.
In the css code, I have a class that I copied from some website and it functions to center any div (hope so!).
Here is the fiddle to it:
http://jsfiddle.net/o3c8768h/1/
HTML:
<div id="micWidgetContainer">
<div id="micWidgetCircle" class="centerme"></div>
<div id="micWidget" class="centerme">
</div>
</div>
CSS:
#micWidgetContainer {
width: auto;
height: 500px;
position: relative;
margin: 0 auto;
}
.centerme {
margin: 0 auto;
display: table;
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-o-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
#micWidgetCircle {
width: 200px;
height: 200px;
position: absolute;
display: block;
margin: 0 auto;
border-radius: 50%;
background: #D0CBCB;
}
#micWidget {
display: block;
width: 200px;
height: 100px;
position: absolute;
border-radius: 40%;
background: #EEE;
z-index: 10;
}
if you want to center vertically and horizontally a block you have to use the position:absolute property and the left, top, bottom and right statements.
i rewrited your .centerme class in order to make it works
.centerme {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
http://jsfiddle.net/o3c8768h/9/