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>
Related
want to create same design for invoice footer in mpdf
i have already tried almost hundred of code but not working in mpdf.
Does any other pdf library in php support css for this kind of design? Code example appreciated.
<style>
.content {
width: 100%;
background-color: white;
}
.diagonal {
border-top: 90px solid #243A53;
border-right: 28px solid white;
height: 0;
width: 50%;
display: inline-block;
float: left;
position: fixed;
bottom: 0;
top:-10%;
z-index: -1;
}
.diagonal1 {
border-bottom: 35px solid orange;
border-left: 25px solid white;
height: 0;
width: 43%;
display: inline-block;
float: right;
position: fixed;
bottom: 0%;
margin-top:52px;
z-index: -1;
}
<style>
<body>
<div class="content" style="position: absolute;bottom: 0">
<div class="diagonal" >
</div>
<div class="diagonal1" ></div>
</div>
<body>
This is what I've got but this doesn't solve the problem for different devices and screen sizes.
<html>
<body>
<iframe src="FILE LINK" width="1920" height="1080"></iframe>
</body>
</html>
How do I make it full screen? I've tried width: 100%; height: 100%
For reaching fullscreen in this case you need to use height: 100vh;, width: 100%;
body {
margin: 0;
}
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.landing {
width: 100%;
height: 100vh;
}
.image-list {
margin: 0;
padding: 0;
list-style: none;
width: 100%;
height: 100vh;
border: 6px solid #00f;
overflow: hidden;
}
.image-list .image {
border: 6px solid #f00;
width: 100%;
height: 400px;
background-size: cover;
background-position: center center;
height: 100vh;
}
.centered-element {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
background: #fff;
padding: 1rem;
width: 280px;
}
.centered-element ul {
margin: 0;
padding: 0;
list-style: none;
}
.centered-element ul span {
opacity: 0.4;
}
<!-- body -->
<section class='landing'>
<ul class='image-list'>
<li class='image'
style='background-image: url(https://unsplash.it/1600/1600)'>
</li>
<li class='image'
style='background-image: url(https://unsplash.it/1600/1800)'>
</li>
<li class='image'
style='background-image: url(https://unsplash.it/1600/1700)'>
</li>
</ul>
</section>
<!-- /body -->
Well, a simple snippet like the following one did the trick for me:
body {
height: 100%;
width: 100%;
margin: 0;
padding: 5px;
box-sizing: border-box;
}
html {
height: 100%;
}
<iframe src="#" width="100%" height="100%"></iframe>
Just play with the containers.
You should of course set your own container sizes to 100% and not html and body.
I am working on my code to create a green circle with your name on it with an arrow and border just like the one that google use.
please find the sample image below.
I have already created a green circle and a name using css and html which you can see it here.
<div class="profileImage">
<span id="profilename" class="profilename"></span>
<div class="flex-container">
</div>
</div>
.profileImage {
-webkit-background-size: 32px 32px;
background-size: 32px 32px;
background-color: green;
-webkit-border-radius: 50%;
border-radius: 50%;
display: block;
float: right;
margin-right: 18px;
margin-top: 12px;
overflow: hidden;
position: relative;
height: 32px;
width: 32px;
z-index: 0;
}
.profilename {
text-align: center;
color: white;
font-size: 14px;
line-height: 32px;
margin-left: 5px;
font-weight: bold;
}
.flex-container {
padding: 0;
margin: 0;
list-style: none;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
justify-content: space-around;
}
$(document).ready(function() {
var firstName = 'Robert';
var lastName = 'Jones';
var intials = firstName.charAt(0)+""+lastName.charAt(0);
document.getElementById("profilename").innerHTML = intials;
});
When I click on a green circle, I want to display the overlay with a border but I have got no idea how to do this. I tried to find it on google but I couldn't find it.
Can you please show me an example how I can display the overlay with a grey border that come with my first name, last name, email address and a signout button?
Thank you.
Ok I'll get you started with an overlay that includes an arrow with a border around the whole thing.
Basically, you're doing a bit of "visual miss direction". We used CSS borders to generate a triangle of the SAME color as the box background. This gets positioned its (height - border width) above the box. This puts the triangle OVER the top of the border, effectively hiding it.
Then there's a second triangle with a color that matches the border of the box. We position this triangle BEHIND the first triangle (using z-index) and offset the second triangle the border width from the first. This makes for a "fake" border because only the border width of the second triangle shows.
body {
margin: 50px;
}
.overlay {
position: absolute;
width: 300px;
height: 200px;
// styling
background-color: #fff;
border: 1px solid #ccc;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2);
border-radius: 4px;
}
.arrow {
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #fff transparent;
top: -9px;
right: 10px;
}
.arrow:after {
content:"";
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #ccc transparent;
left:-10px;
top:-1px;
z-index:-1;
}
<div class="overlay">
<div class="arrow"></div>
<div class="overlayContent">
</div>
</div>
We used two elements (arrow and content) inside the overlay wrapper because we're rounding the corners using overflow:hidden this would cause our arrows to be cut off as well. So instead we'll have an extra container. The content area uses flexbox to push the button bar to the bottom regardless of the size. There are other ways to do this but this is easy.
body {
margin: 50px;
}
.overlay {
position: absolute;
width: 300px;
height: 200px;
// styling
background-color: #fff;
border: 1px solid #ccc;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.2);
border-radius: 4px;
}
.arrow {
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #fff transparent;
top: -9px;
right: 10px;
}
.arrow:after {
content:"";
position: absolute;
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #ccc transparent;
left:-10px;
top:-1px;
z-index:-1;
}
.overlayContent {
position:absolute;
z-index: 1;
top:0; right:0; bottom:0; left:0;
overflow:hidden;
border-radius: 4px;
display:flex;
flex-direction: column;
justify-content: space-between;
}
.top {
flex-basis: 70%;
}
.bottom {
flex-basis: 30%;
border-top: 1px solid #ccc;
background-color: #f5f5f5;
}
<div class="overlay">
<div class="arrow"></div>
<div class="overlayContent">
<div class="top"></div>
<div class="bottom"></div>
</div>
</div>
That's the fundamentals of the overlay. Try filling in the content you want and ask more questions if you need help.
i have this HTML line here (its an echo from php)
echo "
<div class='rowItem'>
<div class='singleItem'>
<div class='itemImage' >
<img src= $arr3[$i] >
</div>
<div class='itemName'>$arr1[$i]</div>
<div class='itemPrice'><br> Php$arr2[$i]
<div class='orderButtonDiv'>
<a href='menu_burger.php'>ORDER</a>
</div>
</div>
</div>
</div>";
Here is the CSS I'm using
.itemImage{
height:100%;
width :100%;
}
.itemImage img{
width: 60%;
left: 0px;
right: 0px;
}
.itemName{
color: red;
text-decoration: none;
font-family: "Roboto",sans-serif;
font-size: 150%;
font-weight: bold;
margin-left: 40%;
margin-top: 4%;
}
.itemPrice{
color: black;
text-decoration: none;
font-family: "Roboto",sans-serif;
font-size: 110%;
margin-left: 41%;
position: absolute;
bottom: 25%;
z-index -1;
}
.singleItem{
width: 48%;
background-color: #e0dede;
border:1px solid red;
height: 150px;
position: relative;
z-index: -1;
}
here picture of the result
as you can see i am not able to resize the image here is the css code. Aside from that it is also overlapping some text
here is the image without the picture without the image
How can i resize the image properly that it will follow the the height of single item and at the same time equate its width to its height
Thank you very much
In my experience, a div with
background:url([imagepath]);background-size:cover;
is the best solution, the css property:
object-fit: cover;
Can help if you want to preseve the img aproach, but is less backwards compatible.
As for the overlaping text, read the documentation for z-index css property.
You will need to apply the background-image as an inline style. You can then add background-size: cover; onto .singleItem in css to control the background image size.
.itemImage{
height:100%;
width :100%;
}
.itemImage img{
width: 60%;
left: 0px;
right: 0px;
}
.itemName{
color: red;
text-decoration: none;
font-family: "Roboto",sans-serif;
font-size: 150%;
font-weight: bold;
margin-left: 40%;
margin-top: 4%;
}
.itemPrice{
color: black;
text-decoration: none;
font-family: "Roboto",sans-serif;
font-size: 110%;
margin-left: 41%;
position: absolute;
bottom: 25%;
z-index -1;
}
.singleItem{
width: 48%;
background-color: #e0dede;
background-size: cover;
border:1px solid red;
height: 150px;
position: relative;
z-index: -1;
}
echo "
<div class='rowItem'>
<div class='singleItem' style='background-image: url(\"{$arr3[$i]}\");'>
<div class='itemName'> {$arr1[$i]}
</div>
<div class='itemPrice'><br> Php{$arr2[$i]}
<div class='orderButtonDiv'><a href='menu_burger.php'>ORDER</a></div>
</div>
</div>
</div>";
I have a searchbar in my header, which I need centered horizontally and just a little bit above the bottom of the header. I was able to achieve this by using
display: flex;
justify-content: center;
align-items: center;
The problem I am having now is that although it is responsive when you make the window smaller horizontally, It is a total mess when you resize the window vertically. I am pretty sure it's because I used margin-top: 350px; to set the vertical position. I also would much rather not use flex display because it isn't supported by much yet. Below is a screenshot of how it looks normaly, and one of how it looks when the view is altered vertically. Also the code pertaining to it. If anyone could help me figure out how to get the searchbar to be responsive vertically, that would be great!
How it is normally:
How it looks when you change the screen size vertically (the searchbar is behind the images):
HTML:
<div class="outcont">
<div id="top" class="header">
<div class="wrap">
<div class="col1"><img class="logoi" src="<?php bloginfo('stylesheet_directory'); ?>/images/main-logo.png" alt="<?php bloginfo('name'); ?> Logo" /></div>
<div class="col2"><?php wp_nav_menu(array('menu' => 'global-nav', 'container' => '')); ?></div>
</div>
<?php get_search_form(); ?>
</div>
CSS:
#searchform div {
shadow: 4px 7px 4px #000000;
margin-top: 350px;
display: flex;
justify-content: center;
align-items: center;
}
#searchform .text {
font-family: 'Merriweather';
padding-left: 35px;
height: 75px;
width: 600px;
font-size: 220%;
color: #B7B7B7;
border-radius: 50px;
background: white url('images/search-img.png') no-repeat;
background-position: 96% center;
}
#searchform .text:focus {
background-image: none;
}
#searchform .text img {
margin-right: 25px;
}
Check out this Fiddle I have made for you.
I have my main div with a background-image and the input inside of that div with the css like so:
#hero {
background: url('https://i.ytimg.com/vi/ReF6iQ7M5_A/maxresdefault.jpg') no-repeat center center scroll;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: relative;
width: 100%;
height: 100vh;
margin-bottom: 0px;
right: 0;
}
#hero input {
position: absolute;
width: 200px;
height: 34px;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
padding: 5px 10px;
border-radius: 50px;
outline: none;
}
This way the textbox will always stay in the center of the image no matter how the browser is scaled. In order for this to work the textbox must have a defined width and height.
So in your case replace your css for the searchbox with the css I have for #hero input and set the parent divs position to relative with position: relative;.
Please let me know how this works out for you.
Hope this helps!