we are developing an cordova Ionic application. For front end we are using html css.
I want to position images to make http://s6.postimg.org/3jnxu7sr5/Home.png
I am done with http://s6.postimg.org/92qhbfpsh/homw_Screen.png
But the remaining i am not able to bring the top image over the center button to achieve the target. I have uploaded my code here https://jsfiddle.net/sweety1112/p36jxhcd/3/embedded/result/ but fiddle has changed much of UI.
If some one could help that would be of much greatful.
<div class="container">
<div class="top">
<h2 class="mid">Scan</h2>
<img src='http://s6.postimg.org/wnc5qggup/home_scan.png'>
</div>
<div class="row">
<img class="applyRotationLeft" src='http://s6.postimg.org/cnhaxjo0h/alphaeon_home_history.png'>
<img class="centerButton" src='http://s6.postimg.org/szrcna2c1/start_btn.png'>
<img class="applyRotationRight" src='http://s6.postimg.org/3orp3w029/home_config.png'>
</div>
<div class="bottom">
<img src='http://s6.postimg.org/6gayuhykx/home_history.png'>
</div>
Regards,
Shraddha
Well if you're going to be rotating the images, there's no need to have five seperate images, it's just more requests and more data usage, since you really need only two images.
If you use
transform-origin: x% x%;
and set it right at the center of the center button somehow, you only need to rotate each of the red things in increments of 90 degrees. I was able to do just that.
HTML:
<div class="container">
<div class="centerButton">
<img src='http://s6.postimg.org/szrcna2c1/start_btn.png'/>
<p>Text</p>
</div>
<div class="top rotate">
<img src='http://s6.postimg.org/wnc5qggup/home_scan.png'/>
<div>
<p>Text</p>
</div>
</div>
<div class="left rotate">
<img src='http://s6.postimg.org/wnc5qggup/home_scan.png'/>
<div>
<p>Text</p>
</div>
</div>
<div class="right rotate">
<img src='http://s6.postimg.org/wnc5qggup/home_scan.png'/>
<div>
<p>Text</p>
</div>
</div>
<div class="bottom rotate">
<img src='http://s6.postimg.org/wnc5qggup/home_scan.png'/>
<div>
<p>Text</p>
</div>
</div>
</div>
and the CSS:
.rotate div{
position: absolute;
padding:0;
margin:0;
width:100%;
height:100%;
left:0;
right:0;
top:0;
bottom:0;
transition: transform 0.5s linear;
}
.centerButton img, .centerButton p{
position:absolute;
width:100%;
top:-50%;
left:-50%;
right:-50%;
bottom:-50%;
margin:auto;
}
.centerButton p{
height:10%;
text-align:center;
}
.centerButton{
width:50%;
height:50%;
margin:auto;
position:absolute;
top:-50%;
left:-50%;
right:-50%;
bottom:-50%;
}
.rotate img{
width:100%;
position:relative;
}
.rotate{
transition: transform 0.5s linear;
position:absolute;
width:72%;
-webkit-transform-origin: 70% 105%;
transform-origin: 70% 105%;
}
.container .bottom, .bottom p{
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.container .left, .right div p{
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
}
.container .right, .left div p{
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.container{
width:250px;
height:250px;
display:block;
position:relative;
}
.rotate div p{
position:absolute;
margin:0;
padding:0;
}
.rotate div p{
top:20%;
left:20%;
}
Here's the fiddle and another I think is a little bit cooler.
NOTE: I only used -webkit- prefix in my fiddle, so you may need to change that in your browser
EDIT: Edited to add what OP asked for in comments
Place the entire image inside one div container. Give each of the five pieces their own id="". Use # to call each id in your css file, put position:relative in all five and use top right bottom & left with px values to maneuver all the pieces into place.
Related
I am trying to position a div in a corner of my screen so that I can resize it to cover the screen.
Problem is, when I resize it the div moves as you can see in the snippet below. I tried to apply the effect on an pseudo-element but it did not help. Any idea how I can resize an item without it moving ?
Thank you for your help.
$('button').click(function(){
$(this).closest('div').find('.cover').toggleClass('active');
console.log("test");
})
.main{
display:flex;
justify-content:space-around;
}
.item {
width:350px;
height:350px;
background-color:teal;
position:relative;
overflow:hidden;
}
.item .cover {
transition:all .5s linear;
width:20px;
height:20px;
background-color:orange;
position:absolute;
inset:-10px -10px auto auto;
border-radius:50%;
}
.item.no-pseudo .cover.active {
width:200%;
height:200%;
}
}
button{
margin-top:1em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sass.js/0.6.2/sass.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="main">
<div class="container">
<div class="item no-pseudo">
<div class="cover"></div>
</div>
<button class="no-pseudo">Click to toggle effect on element</button>
</div>
</div>
You can use transform:scale(x) instead, by default, transform-origin is done from the center of the element.
$('button').click(function(){
$(this).closest('div').find('.cover').toggleClass('active');
console.log("test");
})
.main{
display:flex;
justify-content:space-around;
}
.item {
width:350px;
height:350px;
background-color:teal;
position:relative;
overflow:hidden;
}
.item .cover {
transition:all .5s linear;
width:20px;
height:20px;
background-color:orange;
position:absolute;
inset:-10px -10px auto auto;
border-radius:50%;
}
.item.no-pseudo .cover.active {
transform:scale(50);
}
}
button{
margin-top:1em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sass.js/0.6.2/sass.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="main">
<div class="container">
<div class="item no-pseudo">
<div class="cover"></div>
</div>
<button class="no-pseudo">Click to toggle effect on element</button>
</div>
</div>
Use scale instead of width and height.
$('button').click(function(){
$(this).closest('div').find('.cover').toggleClass('active');
console.log("test");
})
.main{
display:flex;
justify-content:space-around;
}
.item {
width:350px;
height:350px;
background-color:teal;
position:relative;
overflow:hidden;
}
.item .cover {
transition:all .5s linear;
width:20px;
height:20px;
background-color:orange;
position:absolute;
border-radius:50%;
}
.item.no-pseudo .cover.active {
transform:scale(20);
}
}
button{
margin-top:1em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sass.js/0.6.2/sass.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="main">
<div class="container">
<div class="item no-pseudo">
<div class="cover"></div>
</div>
<button class="no-pseudo">Click to toggle effect on element</button>
</div>
</div>
how to make the boxes overlap and offset both top and left 5px one by one only use css
plz check the result what i want first
plz check the upper link
i thought it can be done in just one style define,no need to define each box's location
can u help me adjust it in this code?
HTML
<div class="holder">
<div class="card" ></div>
<div class="card" ></div>
<div class="card" ></div>
<div class="card" ></div>
</div>
CSS
.holder{
position:absolute;
top:100px;
left:100px;
display:block;
font-size: 0;
}
.card{
position:relative;
background:red;
opacity: 0.4;
width:40px;
height:60px;
margin-top:-55px;
margin-left:-35px;
}
thank u vv much
How about minimalising markup and using a box shadow instead?
this allows you to only declare a single card element, and use multiple box shadows:
.holder{
position:absolute;
top:100px;
left:100px;
display:block;
font-size: 0;
}
.card{
position:relative;
background:red;
opacity: 0.4;
width:40px;
height:60px;
margin-top:-55px;
margin-left:-35px;
box-shadow: 5px 5px rgba(255,0,0,0.4),10px 10px rgba(255,0,0,0.4), 15px 15px rgba(255,0,0,0.4), 20px 20px rgba(255,0,0,0.4);
}
<div class="holder">
<div class="card" ></div>
</div>
I have a image gallery of the following structure :
<div class="gallery">
<div class="message">
Welcome to gallery
</div>
<img src="http://placehold.it/300x300" />
</div>
And the CSS :
.message {
position:absolute;
left:10px;
top:20px;
height:30px;
width:140px;
background:#333;
}
.gallery img {
opacity:.85;
}
But this causes the div message also transparent ! How to prevent it and whats the reason for transparency ?
DEMO
It seems the image is on top of the message div. I just swapped them over like this:
<img src="http://placehold.it/300x300" />
<div class="message">
Welcome to image gallery
</div>
And that fixed it for me.
fiddle
Another way is to give the message a z-index like this:
.message {
position:absolute;
left:150px;
top:20px;
height:30px;
width:140px;
background:#333;
z-index: 2;
}
.gallery img {
opacity:.85;
}
fiddle
You could give the image an id so only the image's opacity is lower
#img{ opacity: 85%; }
<img src="http://placehold.it/300x300" id="img" />
Or you could use a class
.img{ opacity: 85%; }
<img src="http://placehold.it/300x300" id="img" />
So then your could would be something like this:
<div class="gallery">
<div class="message">
Welcome to image gallery
</div>
<img src="http://placehold.it/300x300" class="img"/>
</div>
#img{ opacity: 85%; }
.img{ opacity: 85%; }
.message {
position:absolute;
left:10px;
top:20px;
height:30px;
width:140px;
background:#333;
}
Hope this helps you!
Demo
I'm trying to overlay a white circle on top of an image once it is hovered over, however this is trickier than I thought using just CSS. The solution doesn't need to be a strictly CSS one, it's just that I wouldn't like to use images.
HTML/ERB
<div class="item-container">
<div class="rollover-item">
<%= link_to image_tag(#featured_product_first.product.images.order(:placement).first.image.url(:medium)), #featured_product_first.product %>
</div>
<%= link_to #featured_product_first.product.name, #featured_product_first.product %>
<% end %>
</div>
CSS
.item-container {
width: 100%;
height: 100%;
}
.rollover-item {
position: relative;
z-index: 1;
}
.rollover-info img:hover:after {
content: ' ';
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(255,255,255,.5);
border-radius: 50%;
z-index: 10;
}
Assuming this structure
JSFiddle Demo
HTML
<div class="item-container">
<div class="rollover-item">
<img class="product-img" src="http://lorempixel.com/output/technics-q-c-200-200-7.jpg" alt=""/>
<a class="description" href="#">Product Description</a>
</div>
</div>
Then this general CSS should work. Using overflow hidden, absolute positioning and transitioning.
.item.container {
display:inline-block;
}
.rollover-item {
position:relative;
overflow:hidden;
width:200px;
}
.description{
position:absolute;
top:100%;
left:0;
display:block;
width:200px; /* as image */
height:200px; /* as image */
line-height:200px; /* as image */
text-align:center;
text-decoration:none;
color:black;
font-weight:bold;
background:rgba(255,255,255,0.5);
border-radius:50%;
transition:top 0.5s ease;
}
.rollover-item:hover .description {
top:0;
}
look at this example:
html:
<div class="item_cont">
<img src="img_src.jpg" />
<div class="circ"></div>
</div>
css:
.item_cont{width:100px;height:100px;}
.item_cont img{width:100px;height:100px;}
.item_cont .circ{display:none;background:#fff;width:80px;height:80px;border-radius:50%;-moz-border-radius:50%;-webkit-border-radius:50%;}
.item_cont:hover .circ{display:block;}
no js needed.
hope that helps.
use this code:
jsFiddle is here
HTML:
<div class="item-container">
<div class="rollover-item">
</div>
</div>
CSS:
.item-container{
position:relative;
width:200px;
height:200px;
background:tomato; /* I love this color */
}
.rollover-item{
position:aboslute;
width:0%;
height:0%;
margin:0 auto;
background:#fff;
border-radius:50%;
opacity:0;
transition:all 0.5s ease;
}
.item-container:hover .rollover-item{
width:100%;
height:100%;
opacity:1;
}
I'm trying to get my elements centered in one block like this www.spookycraft.net But I haven't been able to figure it out. My code: http://jsfiddle.net/7PP9K/1/
raw code:
<! DOCTYPE HTML>
<html>
<head>
<meta charset='UTF-8'>
<title> Wandercraft Network </title>
<style media="screen" type="text/css">
.slide-up-boxes a{
display:block;
width:300px;
height:300px;
background: #eee;
border: 1px solid #ccc;
overflow:hidden;
}
.slide-up-boxes h5{
height:300px;
width:300px;
text-align:center;
line-height:150px;
-webkit-transition: margin-top 0.3s linear ;
background-color:#white;
}
.slide-up-boxes a:hover h5{
margin-top:-300px;
}
.slide-up-boxes div{
text-align:center;
height:300px;
width:300px;
opacity:0;
background-color:orange;
-webkit-transform: rotate(6deg);
-webkit-transition: all 0.2s linear ;
}
.slide-up-boxes a:hover div{
-webkit-transform: rotate(0);
opacity:1;
}
.slide-up-boxes{
margin:auto;
}
</style>
</head>
<body>
<div id="page-wrap">
<section class="slide-up-boxes">
<a href="www.reddit.com">
<img src="https://dl.dropboxusercontent.com/u/85261154/PVP.png">
<div>
<h5> <img src="http://www.backbonetechnology.com/media/blog-html5-logo.png"> </h5>
</div>
</a>
</div>
<section class="slide-up-boxes">
<a href="www.reddit.com">
<img src="https://dl.dropboxusercontent.com/u/85261154/Kingdoms.png">
<div>
<h5> <img src="http://www.backbonetechnology.com/media/blog-html5-logo.png"> </h5>
</div>
</a>
<section class="slide-up-boxes">
<a href="www.reddit.com">
<img src="https://dl.dropboxusercontent.com/u/85261154/Survival.png">
<div>
<h5> <img src="http://www.backbonetechnology.com/media/blog-html5-logo.png"> </h5>
</div>
</a>
<section class="slide-up-boxes">
<a href="www.reddit.com">
<img src="https://dl.dropboxusercontent.com/u/85261154/Factions.png">
<div>
<h5> <img src="http://www.backbonetechnology.com/media/blog-html5-logo.png"> </h5>
</div>
</a>
</div>
</body>
</html>
I'll be updating this post if I find an answer thank you for reading.
I have updated your jsfiddle.
I've closed the sections and added some CSS to allow for the same presentation as the spookycraft website.
Have a look at this:
http://jsfiddle.net/7PP9K/4/
The key changes:
body{
width:960px;
}
#page-wrap{
width:620px;
margin:0 auto;
}
.slide-up-boxes {
margin:5px;
width:300px;
float:left;
}
edit: wrong jsfiddle link, now updated
The trick to center positioning block elements is
margin: 0 auto;
Just add that to your anchor css (.slide-up-boxes a) or whatever element you want centered and it should work. Make sure it has a fixed width too.
Give the parent a fixed width and center it by automated margins:
#page-wrap {
width:300px;
margin:0 auto;
}
Fiddle sample
CSS :
.slide-up-boxes a {
float:left; // changes made
display:block;
width:300px;
height:300px;
background: #eee;
border: 1px solid #ccc;
overflow:hidden;
}
#page-wrap{
width:620px;
margin:0 auto;
}
body{
width:1200px;
}
DEMO