I have a simple PHP website, that uses PHP only to include another files in index.php, so you may consider it uses HTML only.
The problem is that when viewing a one page of the site in my laptop, it seems to display normally, while viewing it from my smartphone or PC makes it very strange.
Here is the link: strasbourgmeetings.org/rigaCloud/login: you will find two-color page there with a semi-transparent login form in the middle. Well the problem is that only my laptop displays it in the middle, but my PC and other devices are not.
Yes, I know there is a horrible CSS code, but, anyway, I would highly appreciate your help to place this block in the middle.
P.S.: I thought that top: 50%; left: 50% and margin: -25% 0 0 -25% will make it centered, but...
That is the HTML I use:
<div class="white"></div>
<div class="blue"></div>
<div class="heraldry"></div>
<!--</div>-->
<section class="container">
<div class="login">
<div class="loginOpacity"></div>
<h1>Login to RigaCloud</h1>
<form method="post" action="index.html">
<p><input type="text" name="login" value="" placeholder="Username or Email"></p>
<p><input type="password" name="password" value="" placeholder="Password"></p>
<p class="remember_me">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
Remember me on this computer
</label>
</p>
<p class="submit"><input type="submit" name="commit" value="Login"></p>
</form>
</div>
<!--<div class="login-help">-->
<!--<p>Forgot your password? Click here to reset it.</p>-->
<!--</div>-->
</section>
.white {
position: absolute;
top: 0;
width: 100%;
height: 50%;
}
.blue {
position: absolute;
bottom: 0;
width: 100%;
height: 50%;
z-index: -1;
}
.heraldry {
position: absolute;
top: 50%;
left: 50%;
width: 728px;
height: 428px;
margin: -214px 0 0 -364px;
}
.container {
margin: 80px auto 0 -25%;
width: 640px;
position: absolute;
top: 10%;
left: 50%;
}
.containerOpacity {
margin: 90px auto 0 -25%;
width: 640px;
position: absolute;
top: 10%;
left: 50%;
}
.login {
position: absolute;
left: 50%;
top: 50%;
//margin: 0 auto;
margin: 0 auto 0 -25%;
padding: 20px 20px 20px;
width: 310px;
}
.login:before {
content: '';
position: absolute;
top: -8px;
right: -8px;
bottom: -8px;
left: -8px;
}
.loginOpacity {
background: #000;
position: absolute;
width: 310px;
top: -8px;
right: -8px;
bottom: -8px;
left: -8px;
margin: 0 auto;
padding: 20px 20px 20px;
}
Using auto for the left and right-margins will centre an element within its parent (together with other suitable css rules). However, your whole login form is within a section <section class="container"> which is absolutely positioned. You should concentrate on centring this container element, which will probably require removing its absolute positioning.
BTW Your login is also not centred if you reduce your browser's width on your laptop.
Give it a specific width and do margin: 0 auto;
This is my way of centering an element with no specific width.
You can use this method for text, images, buttons etc!
/* The HTML */
<div class="container">
<div class="content"></div>
</div>
/* The CSS */
.container {
float: left;
position: relative;
left: 50%;
}
.content {
float: left;
position: relative;
left: -50%;
}
Related
I have been using PHP and ImageMagick for to generate a 3D preview of a canvas print (see image below).
There are options to change the edge type, depth, size etc which are AJAX calls to a PHP support file which re-renders the preview with new settings and I reload it into the DOM.
This is starting to overload our server when busy. So I thought I could do this in CSS3 and do all the preview rendering client-side instead.
Here's what I have so far:
<div class="wrapper">
<div class="inner">
<div>
<img src="http://lorempixel.com/200/200/nature" alt="Nature">
</div>
</div>
</div>
.wrapper {
perspective: 500px;
margin: 4em auto;
width: 37em;
}
.inner {
transform: rotateY(40deg);
}
.inner div {
width: 11em;
display: inline-block;
margin-right: 1em;
}
.inner img {
display: block;
height: auto;
max-width: 100%;
margin: 0 auto;
}
The problem I am having is wrapping the image around the edges like in the image above. How can I do this?
I have done a demo, with 2 elements holding the same image.
Just set the image origin on them accordingly to the dimension, and it will match.
.main {
width: 400px;
height: 300px;
border: solid 1px red;
background-image: url(http://lorempixel.com/400/300);
background-size: 0px 0px;
perspective: 500px;
position: relative;
}
.front {
position: absolute;
width: 360px;
height: 100%;
left: 40px;
top: 0px;
transform: rotateY(45deg);
transform-origin: left center;
background-image: inherit;
background-position: -40px 0px;
}
.side {
position: absolute;
width: 40px;
height: 100%;
left: 0px;
top: 0px;
transform: rotateY(-45deg);
transform-origin: right center;
background-image: inherit;
background-position: 0px 0px;
}
<div class="main">
<div class="side"></div>
<div class="front"></div>
</div>
I am converting an HTML to pdf file using dompdf. It is working fine. But the problem is that I need to have page margin for all the pages except the first page. The first page should have an image covering the whole page. But now the margin is coming for all pages including the first one.
I am not able to disable margin for the first page. Any help is greatly appreciated. Thanks in advance.
Below is my css
<style type="text/css">
body { margin: 0px; }
#page { margin: 50px; }
#header {
position: fixed;
left: 0px;
top: -52px;
height: 50px;
border-bottom: 2px solid #797979;
margin: 0;
}
#footer {
position: fixed;
left: 0px;
bottom: -52px;
height: 50px;
border-top: 2px solid #797979;
margin: 0;
}
#footer .page:after { content: counter(page); }
.firstpage {
position: absolute;
page-break-after: always;
top: -50px;
width: 100%;
margin: 0;
}
.otherpages{ margin: 0; }
</style>
And here's my html
<div class="firstpage">
<img src="pdf-bg.jpg" style="width:100%; height:auto;/>
</div>
<div id="header">
<p><?php echo date("F j, Y"); ?></p>
</div>
<div id="footer">
<p class="page">Page <?php $PAGE_NUM ?></p>
</div>
<div class="otherpages">
some content
</div>
Try this,
#page { margin: 50px 0; }
.firstpage {
position: absolute;
page-break-after: always;
top: -50px; // compensating for #page top margin
width: 100%;
margin: 0;
}
.otherpages{ margin: 0 50px; }
I'm using Laravel-snappy and am trying to absolutely position 6 columns so that 3 print on each page..
View
...
body {
position: relative;
}
.col1-1 {
text-align: right;
background-color: #00dd00;
position: absolute;
top: 0px;
left: 0px;
width: 250px;
height: 11in;
}
.col1-2 {
text-align: right;
position: absolute;
background-color: #1c94c4;
top: 0px;
left: 270px;
width: 250px;
height: 11in;
}
.col1-3 {
text-align: right;
background-color: #46b8da;
position: absolute;
top: 0px;
left: 540px;
width: 250px;
height: 11in;
}
.col2-1 {
text-align: right;
background-color: #dd0100;
position: absolute;
top: 11in;
left: 0px;
width: 250px;
height: 11in;
}
.col2-2 {
text-align: right;
position: absolute;
background-color: #c4770b;
top: 11in;
left: 270px;
width: 250px;
height: 11in;
}
.col2-3 {
text-align: right;
background-color: #da0073;
position: absolute;
top: 11in;
left: 540px;
width: 250px;
height: 11in;
}
</style>
</head>
<body>
<div class="col1-1"></div>
<div class="col1-2"></div>
<div class="col1-3"></div>
<div class="col2-1"></div>
<div class="col2-2"></div>
<div class="col2-3"></div>
....
Controller
return $pdf->stream('page.pdf');
return view('page');
the problem is that the columns come up short, so the 2nd row start on the 1st page...
I have the pagesize set to letter
'pdf' => array(
'enabled' => true,
'binary' => 'C:\wkhtmltopdf\bin\wkhtmltopdf',
'timeout' => false,
'options' => array('page-size'=>'letter'),
So I'm not really sure what to do next...
I feel like it's a scaling issue?
If I don't use Snappy, and just display the page on the screen and print the screen as a PDF, the results are much better (just a few pixels off), but of course I need the page returned as a PDF.
Snappy uses wkhtmltopdf, which in turn uses Webkit to render the HTML. (Might help you to find more info if my suggestions can't help you as your issue is probably not specifically related to Snappy.)
I think you could solve your issue by preventing the page from breaking inside the columns.. To do that you can use the following CSS on each of the columns:
.col{
page-break-inside: avoid;
}
You might also try wrapping the 3 columns in a div and applying that css on the wrapper div.
You can also try page-break-after: avoid or page-break-before: avoidon the columns or by creating an empty div between the sets of columns and styling it with `page-break-after: always'.
I'm building a website with a CSS popup inside a loop that increments by 1, but the variable $i does not carry on the popup.
CSS
#cover {
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 5;
width: 100%;
height: 100%;
display: none;
}
#score {
height: 380px;
min-width: 280px;
max-width: 380px;
margin: 0 auto;
position: relative;
z-index: 10;
display: none;
background: url(login.png) no-repeat;
border: 5px solid #cccccc;
border-radius: 10px;
}
#score:target,
#score:target + #cover {
display: block;
opacity: 2;
}
.cancel {
display: block;
position: absolute;
top: 3px;
right: 2px;
background: rgb(245, 245, 245);
color: black;
height: 30px;
width: 35px;
font-size: 30px;
text-decoration: none;
text-align: center;
font-weight: bold;
}
.popup {
position: fixed;
left: 50%;
top: 20%;
}
.popup .wrapper {
position: relative;
left: -50%;
}
PHP
<?php $loopvalue = 3; $i=1; while ($i <= $loopvalue) {?>
<li>open popup <?php echo $i;?></li>
<div class="popup">
<div class="wrapper">
<div id="score" style="background-color:#FFF;">
popup # <?php echo $i;?>
×
</div>
<div id="cover" >
</div>
</div>
</div>
The popup number $i never changes. It freezes on 1. I'm not sure what's the problem. I don't see any, but I can't make the popup number change.
In your codes you have repeated the score div with same id. it need to have different ids for different divs
(This will only create proper html. for popup effect it needs to use some java script/JQuery codes)
Try this
<?php $loopvalue = 3; $i=1; while ($i <= $loopvalue) {?>
<li>open popup <?php echo $i;?></li>
<div class="popup">
<div class="wrapper">
<div id="score<?php echo $i;?>" style="background-color:#FFF;">
popup # <?php echo $i;?>
×
</div>
<div id="cover" > </div>
</div>
</div>
<?php $i++;}?>
I have created vertical and horizontal lines with the <hr> html tag, and have them inside a PHP script. The problem I have is that when you zoom on the site, the position of the lines move.
if you zoom (command key +/- on most browsers) the border i've made (with a div) stays in its place, but the horizontal and vertical lines do not.
Another thing I just want to mention is that I was unable to change the CSS script (stylesheet.css) because of the oscommerce 2.2 configuration.. It's a very old version of the oscommerce server and I know it would probably be a better option to upgrade the server and look into templates, but I would like to figure out my problem here.
So let's not talk about CSS since i'm not entitled to use it in this case.
Here is a snippet of the code:
<div style="width:680px;height:540px;border-radius: 20px;-webkit-border-radius: 20px;-moz-border-radius: 20px;-o-border-radius: 20px;border:1px solid #a4a4a4;background-color:#FFFFFF;">
<hr style="width: 0.3px; height: 480px; background: #333; position: absolute; left: 660px; top: 315px;">
<hr style="width: 0.3px; height: 480px; background: #333; position: absolute; left: 890px; top: 315px;">
<hr style="width: 610px; height: 0.3px; background: #333; position: absolute; left: 468px; top: 463px;">
<hr style="width: 610px; height: 0.3px; background: #333; position: absolute; left: 468px; top: 643px;">
<table width="100%" cellspacing="0" cellpadding="15">
</div>
I suggeest to add position:relative to parent DIV and change HR width & height to %
Example:
<div style="width:680px;height:540px;border-radius: 20px;-webkit-border-radius: 20px;-moz-border-radius: 20px;-o-border-radius: 20px;border:1px solid #a4a4a4;background-color:#FFFFFF;position: relative">
<hr style="width: 0.3px; height: 100%; background: #333; position: absolute; left: 33%; top: -9px;">
<hr style="width: 0.3px; height: 100%; background: #333; position: absolute; left: 66%; top: -9px;">
<hr style="width: 100%; height: 0.3px; background: #333; position: absolute; left: 0; top: 33%;">
<hr style="width: 100%; height: 0.3px; background: #333; position: absolute; left: 0; top: 66%;">
<table width="100%" cellspacing="0" cellpadding="15"></table>
</div>
Live: http://jsfiddle.net/ybBwT/
ok i got it problem is you use position:absolute and its in browser behaviour
and solution is give position:relative to its parent div and rearrange your hr position according to you it works i tried in browser here is your hr code i modified it according to me you modify it according to you and don't forget to give position relative to its parent div
<hr style="width: 0.3px; height: 480px; background: none repeat scroll 0% 0% rgb(51, 51, 51); position: absolute; top: 0px; left: 215px;">
<hr style="height: 480px; background: none repeat scroll 0% 0% rgb(51, 51, 51); position: absolute; width: 0.3px; right: 227px; top: 0px;">
<hr style="width: 610px; height: 0.3px; background: none repeat scroll 0% 0% rgb(51, 51, 51); position: absolute; top: 170px; left: 34px;">
<hr style="width: 610px; height: 0.3px; background: none repeat scroll 0% 0% rgb(51, 51, 51); position: absolute; left: 34px; top: 347px;">
That's happening because you have absolute positions in your style... Try blocking all the divs into one div and aligning the hr's with margins instead of "left" and "right"
Your <hr/> has absolute position, so it ok what it's stay in same place while other elements move.
You cannot open <hr/> after <table> tag.
This is wrong:
<table width="100%" cellspacing="0" cellpadding="2">
<hr style="width: 0.3px; height: 480px; background: #333; position: absolute; left: 660px; top: 315px;">
<hr style="width: 0.3px; height: 480px; background: #333; position: absolute; left: 890px; top: 315px;">
<hr style="width: 610px; height: 0.3px; background: #333; position: absolute; left: 468px; top: 463px;">
<hr style="width: 610px; height: 0.3px; background: #333; position: absolute; left: 468px; top: 630px;">
</div>
Need to be for example:
<hr/>
<hr/>
<hr/>
<hr/>
<table width="100%" cellspacing="0" cellpadding="2">
<tr>
<td>
<div>
</div>
.....
</td>
Better to use small png images instead of hr and make it background of <td>, or in last case of <table>