Loading gif align in the center of the page - html

I am trying to make a loading gif to be on the center of the page also in mobiles.
Have tried
margin: 0 auto;
but i had no luck.
#bw-preloader, #bw-preloader:after {
background:url(http://i.imgur.com/ImksiyD.gif) !important;
background-repeat: no-repeat !important;
border-radius: 0% !important;
width: 256px !important;
height: 256px !important;
position: fixed !important;
top: 50% !important;
left: 50% !important;
margin: -50px 0px 0px -50px; !important;
}
#bw-preloader {
border: 0px !important;
-webkit-transition: opacity 10s !important;
position: fixed !important;
top: 50% !important;
left: 50% !important;
margin: -50px 0px 0px -50px; !important;
}
#media only screen and (max-width: 500px) {
#bw-preloader {
position: fixed !important;
top: 50% !important;
left: 50% !important;
margin: -50px 0px 0px -50px; !important;
}
}
You can see it live here
Could someone check it out if im missing something?
Also have tried
position: absolute;

This example code might help.
HTML
<div class="image-container">
<p class="image-holder">
<img src="loading.gif" />
</p>
</div>
CSS
div.image-container {
position: fixed;
top: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
bottom: 0;
background-color: #fff;
z-index: 999999;
text-align: center;
}
.image-holder {
position:absolute;
left: 50%;
top: 50%;
width: 30px;
height: 30px;
}
.image-holder img
{
width: 100%;
margin-left: -50%;
margin-top: -50%;
}
JS
$('div.image-container').delay(350).fadeOut('slow');

You need to adjust your CSS as follows:
#bw-preloader, #bw-preloader:after {
background: url(http://i.imgur.com/ImksiyD.gif) !important;
background-repeat: no-repeat !important;
border-radius: 0% !important;
width: 256px !important;
height: 256px !important;
margin: -128px 0 0 -128px;
}
You need to adjust the top and right margins by half the height and width respectively.

try the following:
position:absolute;
width:256px;
height:256px;
top:50%;
left:50%;
margin: -128px 0 0 -128px;
z-index:1000;
position absolute with the top:50% and left:50% move the elements left top part to the middle that is why you need to give it the negative margin of half the object witdht/height.
hope it helps

Related

Making rounded triangle shape using CSS

I have been trying to create this shape in the bottom left and top right corners of the page. Unfortunately, I have not been able to create the desired look the closest that I have been able to achieve is a pie shape with the following code:
<style>
/* css code that will create, color, and shape
the first accent color area */
#colorAreaOne{
width: 700px;
height: 700px;
background: #3333ff;
opacity: 0.8;
border-radius: 0 700px 0 0;
-moz-border-radius: 0 700px 0 0;
-webkit-border-radius: 0 700px 0 0;
position: fixed;
bottom: 0px;
left: 0px;
}
/* css code that will create, color, and shape
the second accent color area */
#colorAreaTwo{
width: 700px;
height: 700px;
background: #3333ff;
opacity: 0.8;
border-radius: 0 0 700px; 0;
-moz-border-radius: 0 0 700px 0;
-webkit-border-radius: 0 0 700px 0;
position: fixed;
top: 0px;
right: 0px;
}
</style>
If anyone has any information it would be much appreciated. Thank you!
A radial-gradient
div {
width: 700px;
height: 700px;
margin: 1em auto;
background-image: radial-gradient(circle at 100% 0, transparent 0%, transparent 700px, black 700px);
}
<div></div>
You may use a square and use a round pseudo to fill parts of it with a shadow
div {
height:50vw;
width:50vw;
bottom:0;
position:fixed;
overflow:hidden;
}
div:before {
content:'';
display:block;
height:100%;
border-radius:0 0 0 50% ;
box-shadow:0 0 0 50vw turquoise;
<div></div>
border-radius: 50%; overflow: hidden;
.shape{
width: 400px;
height: 400px;
overflow: hidden;
position: relative;
}
.shape:after{
content: "";
position: absolute;
left: -100%;
bottom: -100%;
width: 200%;
height: 200%;
-webkit-border-radius: 50%;
border-radius: 50%;
border: 400px solid;
<div class="shape"></div>
Here is one quick solution that will work if pseudo element is same color as background.
.el {
width: 200px;
height: 200px;
background: black;
position: relative;
overflow: hidden;
margin: 50px;
}
.el:before {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 200%;
height: 200%;
background: white;
border-radius: 50%;
}
<div class="el"></div>

How to add two background images in css

i want help to add two image one over the other and position two images in center
<div class="im1"> </div>
.im1{
position: relative; top: 0; left: 0;
background-image:url("../images/img-shadow.png"),url("../images/img-1.png");
background-size:contain;
height:358px;
background-repeat: no-repeat,no-repeat;
}
background image is with shadow
i want it to be
This actually can be solved only with CSS.
I created an example here that generates the rotated border of the image.
Now you can insert any image inside :)
p.s of course you need to change the width and the height of the image inside to be the same as the frame diagonal. you can use CSS calculate for this.
body {
background-color: #F3F5F6;
}
.shadow:before,
.shadow:after {
content: "";
position: absolute;
z-index: -1;
height: 10%;
max-width: 90%;
width: 90%;
}
.shadow:before {
-webkit-transform: rotate(86deg);
left: -72px;
right: auto;
top: 118px;
box-shadow: 0 15px 5px rgba(0, 0, 0, 0.2);
}
.shadow:after {
-webkit-transform: rotate(84deg);
left: auto;
right: -92px;
bottom: 75px;
box-shadow: 0 -15px 5px rgba(0, 0, 0, 0.2);
}
.rotate {
-webkit-transform: rotate(45deg);
}
.box {
width: 200px;
height: 200px;
position: absolute;
top: 100px;
left: 100px;
}
.pic-wrapper {
width: 100%;
height: 100%;
border: 10px solid #fff;
overflow: hidden;
}
.pic {
background-image: url('http://modernschoolec.com/wp-content/uploads/2015/04/11-980x408.jpg');
background-repeat: no-repeat;
background-size: cover;
background-position: center;
/* (side)(sqrt(2)) */
width: 282px;
height: 282px;
-webkit-transform: rotate(-45deg);
position: relative;
top: -40px;
left: -40px;
}
<div class="box shadow rotate">
<div class="pic-wrapper">
<div class="pic"></div>
</div>
</div>
You could either give the shadow image a z-index of 100 and give the school image a z-index of 101 or set one to be position relative and one to be position absolute, but you will need media queries to make it responsive.
.im1{
background-image:url("../images/img-1.png"),url("../images/img-shadow.png");
height:358px;
background-repeat: no-repeat,no-repeat;
background-position: center , center;
}

Set two images in single background image with nice alignment?

How to set two images in single background-image? I have two pictures but there is an issue with separating this two (one is overlying on another).
Below is my style for that div.
.layout_core_menu_logo {
padding: 20px 0 0px 0;
background: url(~/application/xxx.gif) transparent no-repeat top;
background-size: 968px 200px;
a {
background: url("/application/xx1.gif?c=573") no-repeat,url("/application/themes/xx2.gif")no-repeat;
width:1160px;
height: 187px;
display: block;
text-indent: -9999px;
position: relative; top: 20px; left: 0px;
}
}
You need to specify the position and background size of each image.
.layout_core_menu_logo {
padding: 20px 0 0px 0;
background: url(http://www.mvploops.com/files/_willow/categories/281_Sample- Packs.jpg) transparent no-repeat top;
background-size:100% 100%;
}
a {
background: url("http://www.detailinggurus.com/images/sample_bottles.jpg") no-repeat top left,url("http://www.mclub.com.ua/images/alb/cover42163_148565.jpg")no-repeat top right;
background-size:50% 100%, 50% 100%;
width:968px;
height: 187px;
display: block;
text-indent: -9999px;
position: relative; top: 20px; left: 0px;
}
Sample Fiddle
<style>
a {
background:url("/application/xx1.gif?c=573&c=573") no-repeat scroll 51% 60%,
url("/application/xx2.gif?c=573") no-repeat scroll 0% 20% transparent ;
}
<style>

How to get Different type triangle shapes in css?

Presently I am working on different types of triangle shapes by using border-bottom, border-top, border-left, border-right. Up to this I am getting OK with background color.
But I need to get this shapes by placing background images(without cutting any background images). I tried to do this by using border but no luck.
Example for this
You have 2 ways to get this effect:
The first one is supported only in WebKit, and you will need only one div.
The second one is supported in all modern browsers, but your HTML is less clean, and needs a helper div.
In the code below, test is the first example and test2 and inner2 the second example:
.test {
left: 0px;
top: 0px;
width: 400px;
height: 300px;
position: relative;
border: solid 1px black;
background-image: url(http://placekitten.com/440/330);
display: inline-block;
}
.test:after {
content: "";
position: absolute;
left: 0px;
top: 0px;
right: 0px;
bottom: 0px;
background-image: url(http://placekitten.com/300/400);
background-size: cover;
-webkit-clip-path: polygon(0px 0px, 100% 100%, 0px 100%);
-moz-clip-path: polygon(0px 0px, 100% 100%, 0px 100%);
clip-path: polygon(0px 0px, 100% 100%, 0px 100%);
}
.test2 {
width: 400px;
height: 300px;
position: relative;
border: solid 1px black;
background-image: url(http://placekitten.com/440/330);
overflow: hidden;
display: inline-block;
}
.inner2 {
position: absolute;
width: 140%;
height: 100%;
left: 0px;
top: 0px;
-webkit-transform: rotate(37deg);
-webkit-transform-origin: top left;
transform: rotate(37deg);
transform-origin: top left;
overflow: hidden;
}
.inner2:after {
content: "";
position: absolute;
left: 0px;
top: 0px;
right: 0px;
bottom: 0px;
background-image: url(http://placekitten.com/300/400);
background-size: cover;
-webkit-transform: rotate(-37deg);
-webkit-transform-origin: top left;
transform: rotate(-37deg);
transform-origin: top left;
}
<div class="test"></div>
<div class="test2"><div class="inner2"></div></div>
JSFiddle
The first example uses clipping to get the image cut in triangle shape (only the front image, the other remains rectangular).
The second example uses overflow hidden and a rotation to get the triangular shape. Then, you need the opposite rotation to get the image straight.
In the first example, you can do almost whatever shape you want. For instance,
-webkit-clip-path: polygon(0px 0px, 66% 33%, 33% 66%, 100% 100%, 0px 100%);
gives you this:
.test {
left: 0px;
top: 0px;
width: 400px;
height: 300px;
position: relative;
border: solid 1px black;
background-image: url(http://placekitten.com/440/330);
display: inline-block;
}
.test:after {
content: "";
position: absolute;
left: 0px;
top: 0px;
right: 0px;
bottom: 0px;
background-image: url(http://placekitten.com/300/400);
background-size: cover;
-webkit-clip-path: polygon(0px 0px, 66% 33%, 33% 66%, 100% 100%, 0px 100%);
}
<div class="test"></div>
JSFiddle

popup doesn't apperar on right position

Live site- http://uposonghar.com/new-video/
If you go to that site then hover on embedded YouTube video then 2 sharing button will appear, 1 for facebook & 1 for twitter. After clicking on that button instant share window appear & after 5 second another popup will appear like that-
But that popup doesn't appear on right position, i want to make it center on vertically+horizontally.
My css code-
#reveal-modal-bg {
position: fixed;
height: 100%;
width: 100%;
background: #000;
background: rgba(0,0,0,.8);
z-index: 100;
display: none;
top: 0;
left: 0;
}
.reveal-modal {
visibility: hidden;
top: 100px;
left: 50%;
margin-left: -300px;
width: 520px;
background: #eee;
position: fixed;
z-index: 101;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 0 10px rgba(0,0,0,.4);
-webkit-box-shadow: 0 0 10px rgba(0,0,0,.4);
-box-shadow: 0 0 10px rgba(0,0,0,.4);
text-align:center;
padding:20px 15px 30px;
}
If you declare the height, you could do this to keep the overlay div always be centralized both vertically and horizontally:
.reveal-modal {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
height: 340px; /* must be declared */
}
Check out the demo on JSFiddle.
That is a great article by Stephen Shaw with several ways of achieving absolute centering.
Easiest way I can see would be to copy the way you centered it horizontally:
.reveal-modal { top: 50%; margin-top: -186px; }
This is assuming the box height is usually consistent
Try :
.reveal-modal {
visibility: hidden;
top: 50% !important; // there
-webkit-transform: translateY(-50%); // and there
transform: translateY(-50%); // and there
left: 50%;
margin-left: -300px;
width: 520px;
background: #eee;
position: fixed;
z-index: 101;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 0 10px rgba(0,0,0,.4);
-webkit-box-shadow: 0 0 10px rgba(0,0,0,.4);
-box-shadow: 0 0 10px rgba(0,0,0,.4);
text-align:center;
padding:20px 15px 30px;
}
:)
You dont need to absolute center the element. Neither use CSS3 formulas. Just work with display:table-cell and vertical-align: middle.
Here is a concept of vertical and horizontal centering divs:
<div class="modal-bg">
<div class="modal">
<div class="window">Test</div>
</div>
</div>
And css:
.modal-bg
{
display:table;
width: 100%;
height: 100%;
position:fixed;
left: 0px;
top: 0px;
}
.modal
{
position: relative;
display: table-cell;
vertical-align: middle;
width: 100%;
height: 100%;
}
.window
{
margin: 0 auto;
width:200px;
height: 200px;
background-color: red;
}
Try it out... It will do the trick
http://jsfiddle.net/69skp/1/
first of all remove the top:300px inline style then define the height as height:50% and top:25% and it will become centered