I have a popup div, which is show on click of a an image, i want to show the div on the clicked place. Now that works only if the page is in default position, that is not scrolled or not zoomed. if scrolled or zoomed then the position of popup is changing.
The normal popup
thats ok.
Now when i scroll the page down and click on tht gear image(settings). its like this.
please see tht page is scrolled and the problem. The other on is when i zoom it. If zoomed in its like:
my js is:
$('.settings img').live('click', function (event) {
$('.set_pop').css('left',event.pageX);
$('.set_pop').css('top',event.pageY);
$('.set_pop').css('display','inline');
$(".set_pop").css("position", "fixed");
$(".set_pop").show();
});
my css: and the blue(header) its position is fixed
.settings{
float:right;
margin-right: 3%;
border: none;
margin-top: 5px;
cursor: pointer;
}
.set_pop{
position:absolute;
margin-right: 50px;
margin-top:10px;
width:100px;
-webkit-box-shadow: #666 0px 2px 3px;
-moz-box-shadow: #666 0px 2px 3px;
box-shadow: #666 0px 2px 3px;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
z-index:10;
background-color: #ffffff;
color:#000;
}
html
<div class="settings">
<img src="images/setting.png" alt="settings" width="30px" height="30px"/>
<div class="set_pop">
<ul class="strip">
<li onclick="location.href='register'">Manage Users</li>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>
</div>
</div>
sorry for posting everything, actually i am nt able to get the problem, i tried various scripts and changing all the positions. Someone here could help me out, i hope.
Thanks & regards
Change your class to this :
.set_pop {
background-color: #FFFFFF;
border-radius: 5px 5px 5px 5px;
box-shadow: 0 2px 3px #666666;
color: #000000;
margin-right: 50px;
margin-top: 10px;
position: fixed;
width: 100px;
z-index: 10;
top: 40px;
z-index: 10;
}
What i did is, i changed the position: absolute; to position: fixed; and added "top" and "right" to position it correctly. You can change the top/right accordingly.
Absolute is displayed relative to the document (OR if inside another
element is relative to that element as long as it is not static)
Relative is relative to the document but can be positioned using the
top bottom left & right properties and scrolls with the page
Fixed is displayed fixed to the browser window and therefore doesn't
scroll but moves if your resize the window
For detailed explanation, click here
Related
I'm currently working on opening a window pop-up when I click on a link, but I have problems.
Here's my JavaScript code:
$(function() {
$('.overlay-trigger').click(function(){
$('#expose-mask').fadeIn('fast',function()
{
$('.overlay-box').css({'display':'block'});
});
});
$('#boxclose').click(function()
{
$('.overlay-box').animate({'top':'-200px'},500,function()
{
$('#expose-mask').fadeOut('fast');
});
});
});
my HTML code:
<div class="overlay-box">
<a class="boxclose" id="boxclose"></a>
<h1>Important message</h1>
<p>
Here comes a very important message for your user.
Turn this window off by clicking the cross.
</p>
</div>
<a id="help" class="overlay-trigger" href="#">Help</a>
<div id="expose-mask" style="display: none;"></div>
and my CSS:
#expose-mask
{
background-color: rgba(0, 0, 0, 0.6);
position:fixed;
top:0px;
bottom:0px;
left:0px;
right:0px;
}
.overlay-box
{
background-color: #FFFFFF;
display: none;
position: fixed;
top: 40%;
right: 0;
left: 0;
width: 50%;
margin: 0 auto;
color:#7F7F7F;
padding:20px;
border:2px solid #ccc;
-moz-border-radius: 20px;
-webkit-border-radius:20px;
-khtml-border-radius:20px;
-moz-box-shadow: 0 1px 5px #333;
-webkit-box-shadow: 0 1px 5px #333;
z-index:101;
}
a.overlay-boxclose{
float:right;
width:26px;
height:26px;
background:transparent url(images/cancel.png) repeat top left;
margin-top:-30px;
margin-right:-30px;
cursor:pointer;
}
.overlay-box h1{
border-bottom: 1px dashed #7F7F7F;
margin:-20px -20px 0px -20px;
padding:10px;
background-color:#FFEFEF;
color:#EF7777;
-moz-border-radius:20px 20px 0px 0px;
-webkit-border-top-left-radius: 20px;
-webkit-border-top-right-radius: 20px;
-khtml-border-top-left-radius: 20px;
-khtml-border-top-right-radius: 20px;
}
Currently, if I click on my link, it will open the activator overlay-trigger
I'd like to remove these parts of my JavaScript code: http://prntscr.com/680zzd
I'd like that when the pop-up is open, if I click on my id #expose-mask, it closes the pop-up.
You can have a live preview here: nextgenfocus.com/test/ (click on the "Help" text at the bottom of the page to open the pop-up).
Thanks if you can help me.
the problem is there. when you click on close button , you are changing position top:-200px of overlay-box, but when again you showing the popup you need to giving top:40% position (reset) as same in css.
and you are missing close button text/image
<div class="overlay-box">
<a class="boxclose" id="boxclose">close</a>
<h1>Important message</h1>
<p>
Here comes a very important message for your user.
Turn this window off by clicking the cross.
</p>
</div>
<a id="help" class="overlay-trigger" href="#">Help</a>
<div id="expose-mask" style="display: none;"></div>
js code :
$(function() {
$('.overlay-trigger').click(function(){
$('#expose-mask').fadeIn('fast',function()
{
$('.overlay-box').css({'display':'block','top':'40%'});
});
});
$('#boxclose').click(function()
{
$('.overlay-box').animate({'top':'-200px'},100,function()
{
$('#expose-mask').fadeOut('fast');
});
});
});
see demo
I have this div here:
<div style="
width: 259px;
height: 201px;
background-color: #282c2f;
box-shadow: 0px 8px 10px #000;
border-radius: 10px;
border: 2px solid #282c2f;">SHOP</div>
That when a user hovers, the grey box needs to slide down into a teal box. So the new color is shown, and a link is ready to be clicked.
It should slide into:
<div style="
width: 259px;
height: 201px;
background-color: #00e7b4;
box-shadow: 0px 8px 10px #000;
border-radius: 10px;
border: 2px solid #282c2f;"><a href="shop.htm">SHOP</div>
Is there anything where I can see an effect similar to this working? Perhaps plugin suggestions? Not sure how to start on this.
Very similar to what I am looking for, except the black disappears as it slides out of the div: http://jsfiddle.net/bUcZg/
I believe this is what you're trying to accomplish. I haven't tested for browser compatibility, so you may want to do that and play around with it.
Basically just involved adding an additional div, and using slideDown on the new div.
<div id="newTarget" style="display:none;width:100px; height:100px; background-color:teal; border: teal solid 1px; position:absolute;">
<a id="newTargetLink" href="#">Link</a>
</div>
http://jsfiddle.net/bUcZg/22/
You can chain animations in jQuery. If I understand you correctly you could do it like this:
trigger.hover(function() {
target.animate({top: 0}).animate({opacity : 0});
}
Example: http://jsfiddle.net/bUcZg/21/
Im looking for something like this
There is a small description ($10 USD ) given for the button. Can anyone help me how to create one?
I have an anchor button like this.Can any one help me create such a description using css?
<a style="float:right" class="iframe button pink" href="">Pay Now</a>
this is the fiddle
http://jsfiddle.net/wLmbw/
If it's static content you could add a small container via a :before element.
.button.pink{
position: relative;
}
.button.pink:before{
position: absolute;
left: -90%;
top: 0;
display: block;
padding: 10px;
width: 30px;
height: 10px;
content: "$10";
background: #6FCC49;
border: 1px solid #679500;
color: white;
text-shadow: 1px 1px 0 #679500;
border-radius: 5px;
text-align: center;
}
http://jsfiddle.net/etasf/2/
This could probably be cleaned up - this was just my quick run at it.
add another html element like the picture on the left,
position it using css
and use javacsript to populate the right value
i'm guessing you know how to style an div, or span, element. Place it right next to the button and set it to css.display:none. And when the user hovers over the button, then set it to css.display:block using javascript...
You might want something along these lines:
HTML:
<a style="float:right" class="iframe button pink" href="">
<span class="label">10 USD</span>Pay Now</a>
CSS
.pink{
position:relative;
}
.label
{
box-sizing:border-box;
text-align:center;
position:absolute;
right:105%;
bottom: -1px;
padding-bottom:5px;
padding-top:5px;
display:inline-block;
width: 50px;
height: 18px;
background-color:pink;
border-radius:5px;
border:1px solid black;
}
JSFiddle
Elements within clickable h2
Introduction
I am creating a one-line menu in html. I have 3 options that work in a really similar way. The problem is that the one that has the html right, looks like it can fail more easily. I put the 3 examples here. I am looking for reliable, browser-compatible menu. The third option uses javascript so I don't really love it.
The menu has to be 100% width, within a gray rectangle and has to have some text at left and some at right. The entire menu has to be clickable with only one hyperlink. This is what I have tried so far:
Implemented examples
A link to see them all working is here (DISCLAIMER: yes, it is my own webpage). If you don't feel like clicking there, here's an image of how they look in the same order as the options:
Option 1.
This one is no html compliant, but I've found is the one more logical, it behaves better in general and it's not likely to give many troubles:
<a href="http://newfutureuniversity.org/test/hblock.php">
<h2 style="width:100%; height:100%; border: 1px solid #AAA; padding: 0px 0px 0px 5px; background-color: #EEE;">
Hello world
<span style="margin: 6px; color:gray; font-size: 15px; float:right; ">
Right text
</span>
</h2>
</a>
Option 2.
This one is html compliant, but I just hate to center things using pixels. I feel like it will break really easily. Besides, the text in the right is not fully clickable:
<h2 style="border: 1px solid #AAA; padding: 0px 0px 0px 5px; background-color: #EEE;">
<a href="http://newfutureuniversity.org/test/hblock.php" style="width:100%; height:100%; display:block;">
Hello world
</a>
<span style="position: relative; right: 6px; top:-23px; color:gray; font-size: 15px; float:right; ">
Right text
</span>
</h2>
Option 3.
This one uses javascript. I prefer not to bloat every menu like this one with javascript and to use html/css is available, but this is another option. It doesn't get the color that regular links do.
<h2 onclick="location.href='http://newfutureuniversity.org/test/hblock.php';" style="cursor:pointer; display: block; width:100%; height:100%; border: 1px solid #AAA; padding: 0px 0px 0px 5px; background-color: #EEE;">
Hello world
<span style="margin: 6px; color:gray; font-size: 15px; float:right; ">
Right text
</span>
</h2>
Question
Which one do is more browser compatible and unlikely to break? Do you have any other recommendation or improvement? Any feedback will be appreciated
PS, all the inline CSS will be put apart in a different css sheet.
I'd suggest that the better approach is to reorganise your HTML, to the following:
<h2>
Hello world<span>Right text</span>
</h2>
And then use the following CSS:
a {
display: block;
padding: 0.2em;
width: 80%;
margin: 0 auto;
border: 1px solid #000;
background-color: #aaa;
}
a span {
color: #000;
float: right;
text-decoration: none;
font-size: 0.8em;
padding-top: 0.2em;
}
JS Fiddle demo.
The validity of this depends on the elements you want to ultimately place within the h2 tag to remain clickable, though. Under HTML5 it's valid to nest block-level elements within an a tag, under HTML4, though, while it still seems to work it's not considered valid, according to the doctype.
But, for the posted requirements this seems to work; albeit it does require the restructuring of your HTML, which may not be possible. However:
it is valid HTML,
it's resistant to breaking (unless the content of the span exceeds a given width,
it doesn't rely on arbitrary px adjustments (albeit it does use padding to vertically centre the resized text within the a),
it doesn't require JavaScript
Edited to amend the CSS a little, to account for the potential for the right-floated text to become large enough to overflow to the next line, by simply adding overflow: hidden to the a element's CSS:
a {
display: block;
padding: 0.2em;
width: 80%;
margin: 0 auto;
border: 1px solid #000;
background-color: #aaa;
overflow: hidden;
}
JS Fiddle demo.
You could also, of course, add a max-width to the span:
a span {
color: #000;
float: right;
text-decoration: none;
font-size: 0.8em;
padding-top: 0.2em;
max-width: 80%;
}
JS Fiddle demo.
I agree with David Thomas on his mark up. Although I would alter the css slightly in order to make it more robust. If you resize your browser so that the right span gets pushed below the left text (make the browser smaller), then you'll see that the clearing properties that I have applied mean the a stays wrapped around the span rather than allowing the span to move outside of the a area.
HTML:
<h2 class="item ">
<a href="#" >Loads of left left Left Text<span>Right Text lots more</span></a>
</h2>
CSS:
.item a {
zoom:1;
border: 1px solid #666;
background: grey;
display: block;
}
.item a:before,
.item a:after {
content:"";
display:table;
}
.item a:after {
clear:both;
}
.item span {
background: green;
float: right;
}
DEMO:
http://jsfiddle.net/Vc3DA/
I need to shape ONE div tag in the following shape:
Is it possible to make it cross browser? I don't necessarily need rounded corners. I need it so I can change the color of the borders of the whole div on hover, so I assume it can't be achieved by using two divs.
Yeah, you can do that using HTML and CSS like this: http://jsfiddle.net/broofa/364Eq/
It's essentially using three divs to aggregate the mouse events, like so:
<div id="outer">
<div class="inner"></div>
<div class="inner"></div>
</div>
And I use a :hover rule on the outer element to affect the border colors on the inner divs:
#outer .inner {border-color: red}
#outer:hover .inner {border-color: blue}
The only quirk with this markup is that the content area - the area you drew in your image - is that it's two divs, not one. So text won't wrap and flow the way you might expect. Also, this may not work so well on older (IE6-7) browsers. But FF, Chrome, Safari, Opera should probably be okay.
A one div solution using pseudo elements:
/* relevant styles for shape */
.tab {
border-top-left-radius: 0px;
margin-left: 100px;
}
.tab:before {
content:"";
display: block;
position: relative;
height: 50px;
width: 50px;
right: 52px; /* width + border width */
top: -2px;
background-color: white;
border: inherit;
border-right-width: 0px;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
/* styles to look like example */
div{
box-sizing: border-box;
background-color: white;
border: 2px solid red;
height: 100px;
width: 200px;
border-radius: 5px;
}
div:hover {
border-color: green;
}
<div class="tab"></div>
See this jsFiddle example:
<div id="main">
<div id="div1" class="border">
</div>
<div id="div2" class="border">
</div>
</div>
You can either use a map or use 2 divs and alter the borders so it looks like one shape.
two options that I can think of:
1) give the div a background image and use CSS pseudo class :hover to change the background image to one that indicates a hover state
2) put three div's inside a wrapper, and position them so so you have one in the upper left hand corner, and then two stacked on top of each other, so that you can simulate the top half of a larger div missing the upper left half border. I don't think CSS alonw can target all the divs in order to change their borders, so will probably have to use JS to execute the hover behavior, by applying an event handler to all three divs.
No. Divs are ALWAYS rectangular. You could fake it in a number of ways (using a background image would be one option).
As for using two DIVs, sure you could. The hover could be done with CSS3 and child selectors of a parent div or you could JavaScript to change the class of both divs when hovering over either one of them.
Definitely requires two or three div's unless you use a background image
Here's a three-div solution
http://jsfiddle.net/pxfunc/SUuF6/
Its cross-browser compatible. The hover won't work in IE6, but it will in IE7+. The rounded corners will show based on browser support
HTML:
<div id="fancyShape">
<div id="main"><div></div>
<div id="panHandle"></div>
</div>
CSS:
#fancyShape {position:relative;width:504px;height:304px;}
#main {
margin-left:100px;
width:400px;
height:300px;
border:solid 2px #000;
border-radius:0 15px 15px 15px;
}
#panHandle {
width:100px;
height:120px;
position:absolute;
top:0;left:0;
border-top:solid 2px #000;
border-left:solid 2px #000;
border-bottom:solid 2px #000;
border-radius:15px 0 0 15px;
}
/* hover effect */
#fancyShape div {background-color:#fff;}
#fancyShape:hover div {background-color:#ff0;border-color:red;}
Perhaps you could use Border-radius along with 2 or 3 div's to get the look you want. The only issue then is it's not supported in all browsers.
Use multiple divs, as others have suggested.
http://jsfiddle.net/thomas4g/7B5MA/14/
Keep in mind that it'll be very hard to flow content in this.
<!DOCTYPE HTML>
<html>
<head>
<style>
html{height: 100%; width: 100%;}
body{height: 100%; width: 100%;}
#wrapper{
position: relative;
top: 50px;
right: 25%;
width: 565px;
height: 440px;
margin: 0 auto;
padding: 0px;
}
#left{
position: absolute;
width: 100px;
height: 50px;
border: 2px solid black;
border-right: none;
-moz-border-radius-bottomleft: 10px;
border-bottom-left-radius: 10px;
-moz-border-radius-topleft: 10px;
border-top-left-radius: 10px;
background-color: #ffffff;
}
#right{
position: absolute;
left: 100px;
width: 440px;
height: 440px;
border: 2px solid black;
-moz-border-radius: 10px;
-moz-border-radius-topleft: 0px;
border-top-left-radius: 0px;
border-radius: 10px;
padding-left: 25px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
$('#wrapper').hover(
function () {
$(this).children('#left').css({'border':'2px solid red', 'border-right':'none'});
$(this).children('#right').css({'border':'2px solid red'});
},
function () {
$(this).children('#left').css({'border':'2px solid black', 'border-right':'none'});
$(this).children('#right').css({'border':'2px solid black'});
});
});
</script>
</head>
<body>
<div id="wrapper">
<div id="right">Some content here</div>
<div id = "left"></div>
</div>
</body>
</html>
You can use CSSPIE for rounded orners for IE