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/
Related
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
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
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/
Hi i am currently making a demo site from just pure html/css/javascript usually i would be using ruby and just rendering partials to solve this issue but to get some practice with javascript i though this might be an interesting challenge, and it has been! so what i have made is a block of code that has an image that is word wrapped with text. and i have positioned buttons either side of the block of content. my objective is to have those buttons hide until mouse over and onclick the content with the image will rotate to a a different image and description. and those blocks of collections will be grouped into tabs. for for instance on the home tab there will be four collections of content i could rotate through them, then the next tab would be products and if i clicked on that tab there would be three collections of content one for each product, and each would contain an image and a description..
cool so what i have so far is this here is my html:
<div class='content'>
<div class='box'>
<ul id="navigation">
<li class="two">Home</li>
<li class="three selected">Products</li>
<li class="four">Technology</li>
<li class="five">Cosulting</li>
<li class="six">Contact</li>
</ul>
<div id="sub_content">
<div class='title'>
<h3> Home </h3>
</div>
<div class="clear"></div>
<div class="arrow">
<a id="left" href=""><img src="/home/***/HTML/launch_pad/images/lefta.png">/a>
<a id="right" href=""><img src="/home/***/HTML/launch_pad/images/righta.png"></a>
</div>
<div class="clear"></div>
<div id="wall">
<div class="hide">
<div class="description">
<img id="demoimg" src="/home/***/HTML/launch_pad/images/productivity.png" alt="demo pic">
<h2>Who are we?</h2>
<p>a super hero organization fighting evil all day long!! .</p>
</div>
#the description class is then repeated each with a unique image and new info in the <h2> tags and the <p> tags..
i have found several things that i have found online that have been helpful but i have conflicting javascript lib errors. so i am using the so that i can use the easing 1.3 library and for the twitter widdget i am using.
my css looks like this:
.content {
margin-left: 5%;
margin-right: 5%;
width: 1400px;
}
.box {
float: left;
width: 950px;
margin-left: 20px;
position: relative;
}
#sub_content {
background-color: white;
width: 720px;
max-height: 462px;
min-width:600px;
margin: 0px 0px 0px 40px;
padding: 15px;
border: solid 1px black;
border-radius: 8px 8px 8px 8px;
overflow-y: auto;
}
.title {
text-align: right;
text-transform: uppercase;
border: 1px solid yellow;
margin: 0px 25px 5px 25px;
padding: 5px;
}
#wall {
min-width: 300px;
margin:0px 0px 15px 15px;
width:655px;
border: 1px solid red;
float: left;
padding: 5px;
}
.description {
margin: 0px 0px 10px 10px;
padding: 5px;
width: 630px;
border:1px solid green;
float: left;
}
#decription p {
word-wrap: break-word;
}
#demoimg {
float: left;
margin: 16px 8px 0px 0px;
height: 200px;
width: 200px;
}
EDIT:
this is the javaScript i was trying:
<script type="text/javascript">
<!--
window.addEvent('domready', function() {
var opt = {
slides: 'description',
duration: 1500,
buttons: {next:'right',prev:'left'},
transition: Fx.Transitions.Quint.easeOut
}
var scroller = new QScroller('content',opt);
scroller.load();
});
//-->
</script>
but this doesnt seem to work i have a file with all my javascript in my directory that i link to..
the one that has come really close is at http://www.latenight-coding.com/mootools/classes/qscroller.html under Horizontal scroller with text and images. but it doesnt work!! which makes me pull out my hair. is there another way to just loop through the description and hide the ones that arnt selected??
any help or a better reference's would be much appreciated :D
You might consider using Jquery Cycle. It is an OUTSTANDING plugin that uses easing, and will allow you to have both a description of your content and prev/next buttons or links. You can also have multiple slideshows on one page, and it is probably not a hair-puller to have a link to one slideshow open up several, as this seems to be what you are looking for.
It works pretty easily out of the box and is highly customizable. The website has a ton of examples with code.
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