So I want the button to link to page 2 at a certain height, like Wikipedia
I've tried linking it but it doesn't seem to do anything
<div class="button1">
<button><a id="#areas.html#location1"></a>Button1</button></div>
CSS
.button1 {
position: absolute;
top: 28%;
left: 22.2%;
}
Page 2
This is what you need.
Just use a button with link to another page then div or a and give it name="location1" to go direct to that section of the page.
Button to another page
<button onclick="location.href='areas.html#location1'" type="button">Button1</button>
If your area.html file
<div name="location1">
content
</div>
Okay after some trial and error and using the comments I think I fixed it allowing it to use the tag (also removed the hyperlink underline and color)
Credit for helping goes to Raptor & AlwaysHelping
This is linking button
<button> Button words</button>
This is the target div
<div id="locationlink1"></div>
And the CSS for color changing the hyperlink color to black
a
{
color: #000000;
}
Related
Until now I got a webpage with a navigation bar, which is responsible to screensize, all is fine until this point.
But now it becomes a bit strange for me, I want to add a search icon (loupe) in the bottom left hand corner. My idea was to use the "aside" element (or "aside" section?) which is supported in html5, but if I put my icon in this aside element it is not visible. I hope you can help me. here some html code:
HERE IS SOME OTHER CODE WHICH WORKS PERFECT
.
.
.
<!-- Search Icon beginn -->
<aside>
<div class="searchicon">
<img src="img/Searchicon.png" alt="Search" height="30px" width="30px">
</div>
</aside>
<!-- Search Icon end -->
</body>
My plan is that the search icon is always on the left of the webpage (kind of a sidebar), I don't want to cover up the text which is at the site later on.
Thanks to you!
Try changing the z-index in css which will basically move an HTML element forward/backward :
.searchicon {
z-index: 2;
}
/*
Set the value to negative if you want the element to move backwards.
*/
The positioning of HTML elements is controlled in your CSS. In your case this is the searchicon class. You haven't provided the CSS but it might look something like this:
.searchicon {
position: fixed;
left: 150px;
bottom: 150px;
z-index: 2;
}
As a note, the aside element may not be the "most semantic" option based on what you've described. The HTML5 aside is intended to contain content that doesn't directly relate to the pages primary content. For example a sidebar containing related articles.
I have several folder icons that are created with the template:
<div id='folderTemplate' class="template openclosed_folder_icon subfolder" style="position:absolute; top:'30'; left:'100';">
<img class="folder_icon" src="images/folder_closed.png" alt="closed folder" />
<div class="folder_label" >name</div>
<img class='folder_redX' src='images/redX.png' alt='redX' title='Delete this gallery' />
</div>
The folders look like this:
If I left-click most folders, the e.target that comes into jQuery is the first <img> element, above, just below the opening <div> tag. And if I right-click these folders with Chrome Debugging turned on, to inspect them, the element selected is this first <img> element. But one of the folders gives me the outer <div>, when I left click it or right-click it. Does anyone have an idea what's going on? What controls which element is actually selected by a left or right click?
Thanks
My best guess would be, the <img /> element might have unselectable styles:
pointer-events: none;
The above code will make sure that the mouse pointer doesn't see that image at all, or any element for the reason.
Check this out here:
input {padding: 25px 35px;}
div {pointer-events: none; position: relative; top: 15px; background: #fff; display: inline-block; left: -205px; z-index: 9999;}
<input type="button" value="Hello, World! Click Me?" />
<div>See through! Click on me!</div>
In the above snippet, if you try to click on the <div /> you won't be able to do, and the pointer events directly go to the element behind it. Logically, the mouse doesn't see the <div /> at all! Most of the reason is because of the CSS behind it, which you haven't provided, might answer this question! :)
To make it sure, I have also added z-index: 999; to the <div />. Still the <div /> is unselectable.
I solved this but it wasn't what I thought. The problem was that the template div for the folder to the left extends too far right and overlaps the folder on the right:
So when I thought I was clicking on the images folder I was actually clicking on the template div of the Gallery folder, which blocked the mouse click from reaching the images folder. The click wasn't bringing up the template div of the images folder. It was bringing up the template div of the Gallery folder that overlayed the images folder. Fix was to make the width of the template div just enough to hold the folder name so there won't be any more overlapping of folders.
I am a total newbie at CSS. The problem I have is really simple.
<section>
<fieldset>
<div>
This div block contains the label field and the files.
</div>
</fieldset>
</section>
This is a part of my HTML code. Inside the div block I have a field and some script that helps me in uploading multiple files. What I want to do is show something like a grey-div-block over the section or div itself that takes up the space and shows a gif image while the files are being uploaded.
The problem: I don't know how to work out with css. I am looking only for some css classes that I can add to my code and do what I want. I know how to fix the jquery.
Use html like this
<div class="load">
<img src="../path">
</div>
And the css is
.load{background-color: Gray; filter: alpha(opacity=80); opacity: 0.8; z-index: 10000; text-align:center; position:absolute;}
may it will help you
just insert wherever you want it placed.
<div class="loading">
<img src="loading.gif">
</div>
EDITED:demo with gif , here when you click on the button the popup appears and when you click on gray backgrond the popup dissappears.
Include your gif inside the div popup and ofcourse style it according to your needs , this will display a centered loading gif , use display:none to both the divs initially and then using some jquery try to make them visible , I hope it helps you
If I understand you correctly, you want something like a modal popup, but just over that section (not the whole page), showing progress image and preventing further clicks on the upload field? If so, then just use this:
<section>
<div id="modal" style="display: none"><img src="..."></div>
<fieldset>
<div>
This div block contains the label field and the files.
</div>
</fieldset>
</section>
You show it with:
document.getElementById('modal').setAttribute('style', 'height: 100%; width: 100%; z-index: 1000; background-color: Gray; opacity: 0.5');
And hide it again with:
document.getElementById('modal').setAttribute('style', 'display: none');
Here is what I am trying to accomplish in HTML/CSS:
I have images in different heights and widths, but they are all under 180x235. So what I want to do is create a div with border and vertical-align: middle them all. I have successfully done that but now I am stuck on how to properly a href link the entire div.
Here is my code:
<div id="parentdivimage" style="position:relative;width:184px;height:235px;border-width:2px;border-color:black;border-style:solid;text-align:center;">
<div id="childdivimage" style="position:absolute;top:50%;height:62px;margin-top:-31px;">
<img src="myimage.jpg" height="62" width="180">
</div>
</div>
Please note that for the sake of copy pasting here easily, the style code is inline.
I read somewhere that I can simply add another parent div on top of the code and then do a href inside that. However, based on some research it won't be valid code.
So to sum it up again, I need the entire div (#parentdivimage) to be a href link.
UPDATE 06/10/2014: using div's inside a's is semantically correct in HTML5.
You'll need to choose between the following scenarios:
<a href="http://google.com">
<div>
Hello world
</div>
</a>
which is semantically incorrect, but it will work.
<div style="cursor: pointer;" onclick="window.location='http://google.com';">
Hello world
</div>
which is semantically correct but it involves using JS.
<a href="http://google.com">
<span style="display: block;">
Hello world
</span>
</a>
which is semantically correct and works as expected but is not a div any more.
Why don't you strip out the <div> element and replace it with an <a> instead? Just because the anchor tag isn't a div doesn't mean you can't style it with display:block, a height, width, background, border, etc. You can make it look like a div but still act like a link. Then you're not relying on invalid code or JavaScript that may not be enabled for some users.
Do it like this:
Parentdivimage should have specified width and height, and its position should be:
position: relative;
Just inside the parentdivimage, next to other divs that parent contains you should put:
<span class="clickable"></span>
Then in css file:
.clickable {
height: 100%;
width: 100%;
left: 0;
top: 0;
position: absolute;
z-index: 1;
}
The span tag will fill out its parent block which is parentdiv, because of height and width set to 100%. Span will be on the top of all of surrounding elements because of setting z-index higher than other elements. Finally span will be clickable, because it's inside of an 'a' tag.
Going off of what Surreal Dreams said, it's probably best to style the anchor tag in my experience, but it really does depend on what you are doing. Here's an example:
Html:
<div class="parent-div">
Test
Test
Test
</div>
Then the CSS:
.parent-div {
width: 200px;
}
a {
display:block;
background-color: #ccc;
color: #000;
text-decoration:none;
padding:10px;
margin-bottom:1px;
}
a:hover {
background-color: #ddd;
}
http://jsbin.com/zijijuduqo/1/edit?html,css,output
Two things you can do:
Change #childdivimage to a span element, and change #parentdivimage to an anchor tag. This may require you to add some more styling to get things looking perfect. This is preffered, since it uses semantic markup, and does not rely on javascript.
Use Javascript to bind a click event to #parentdivimage. You must redirect the browser window by modifying window.location inside this event. This is TheEasyWayTM, but will not degrade gracefully.
I'm surprised no one suggested this simple trick so far! (denu does something similar though.)
If you want a link to cover an entire div, an idea would be to create an empty <a> tag as the first child:
<div class="covered-div">
<a class="cover-link" href="/my-link"></a>
<!-- other content as usual -->
</div>
div.covered-div {
position: relative;
}
a.cover-link {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
This works especially great when using <ul> to create block sections or slideshows and you want the whole slide to be a link (instead of simply the text on the slide). In the case of an <li> it's not valid to wrap it with an <a> so you'd have to put the cover link inside the item and use CSS to expand it over the entire <li> block.
Do note that having it as the first child means it will make other links or buttons inside the text unreachable by clicks. If you want them to be clickable, then you'd have to make it the last child instead.
In the case of the original question:
<div id="parentdivimage" style="position:relative;width:184px;height:235px;border-width:2px;border-color:black;border-style:solid;text-align:center;">
<a class="cover-link" href="/my-link"></a> <!-- Insert this empty link here and use CSS to expand it over the entire div -->
<div id="childdivimage" style="position:absolute;top:50%;height:62px;margin-top:-31px;">
<img src="myimage.jpg" height="62" width="180">
</div>
<!-- OR: it can also be here if the childdivimage divs should have their own clickable links -->
</div>
Make the div of id="childdivimag" a span instead, and wrap that in an a element. As the span and img are in-line elements by default this remains valid, whereas a div is a block level element, and therefore invalid mark-up when contained within an a.
put display:block on the anchor element. and/or zoom:1;
but you should just really do this.
a#parentdivimage{position:relative; width:184px; height:235px;
border:2px solid #000; text-align:center;
background-image:url("myimage.jpg");
background-position: 50% 50%;
background-repeat:no-repeat; display:block;
text-indent:-9999px}
<a id="parentdivimage">whatever your alt attribute was</a>
This can be done in many ways.
a. Using nested inside a tag.
<a href="link1.html">
<div> Something in the div </div>
</a>
b. Using the Inline JavaScript Method
<div onclick="javascript:window.location.href='link1.html' ">
Some Text
</div>
c. Using jQuery inside tag
HTML:
<div class="demo" > Some text here </div>
jQuery:
$(".demo").click( function() {
window.location.href="link1.html";
});
I simply do
onClick="location.href='url or path here'"
What I would do is put a span inside the <a> tag, set the span to block, and add size to the span, or just apply the styling to the <a> tag. Definitely handle the positioning in the <a> tag style. Add an onclick event to the a where JavaScript will catch the event, then return false at the end of the JavaScript event to prevent default action of the href and bubbling of the click. This works in cases with or without JavaScript enabled, and any AJAX can be handled in the Javascript listener.
If you're using jQuery, you can use this as your listener and omit the onclick in the a tag.
$('#idofdiv').live("click", function(e) {
//add stuff here
e.preventDefault; //or use return false
});
this allows you to attach listeners to any changed elements as necessary.
A link with <div> tags:
<div style="cursor: pointer;" onclick="window.location='http://www.google.com';">
Something in the div
</div>
A link with <a> tags:
<a href="http://www.google.com">
<div>
Something in the div
</div>
</a>
I have 3 links that represent the content for one iFrame in my page. When you click each link, it'll reload the contents of that iFrame without reloading the page.
how do i set the image of my link to change when it's active?
here's my code:
<div id="tabs">
<div id="overview">
<a id="overviewtab" target="tabsa" href="toframe.html">Overviews</a>
</div>
<div id="gallery">
<a target="tabsa" href="tawagpinoygallery.html">Gallery</a>
</div>
<div id="reviews">
<a target="tabsa" href="trframe.html">Reviews</a>
</div>
</div>
<div id="tabs-1">
<!--<div id="scroller">-->
<iframe name= "tabsa" width="95%" height="100%" frameborder="0"></iframe>
</div>
CSS code:
#gallery a {
text-indent: -9999px;
padding-top: 40px;
background: url(../images/GalleryTab.png) no-repeat;
height: 51px; width: 123px; position: absolute; z-index: 2;
}
#gallery a:active, a:hover {
text-indent: -9999px;
padding-top: 40px;
background: url(../images/galleryoverview.png) no-repeat;
height: 51px;
width: 123px;
position: absolute;
z-index: 2;
}
it doesn't seem to work.. :o i only see the change in image when i hold the mouse down on the link, but when i click it, the image remains the same as if it wasn't the active tab. :o thanks!!
I am not seeing a style for visited? Only active and hover.
add
#gallery a:visited{}
style and see if that helps.
But I wonder if that is what you are actually asking? You may want to link to be displayed differently from the other links if its the last link that the user clicked. To do that you may have to use some javascript.
For example, if you use jQuery you can do something like this:
$("#gallery a").click(function(){
$("#gallery a").removeClass("ActiveClass");
$(this).addClass("ActiveClass");
});
where ActiveClass is a CSS class for styling the link appropriately.
EDIT based on comment below.
Let us assume that you have three links that look the same (call that lookA). You click on one and it looks different from the other two (lookB) but the other two still looks the same (lookA). You then click on a second link. The second link is not lookB and the other two links are lookA. Does this sound like what you want? At least that is how I interpret your question.
Hence, create two classes in CSS:
.lookA {/*Style for lookA*/}
.lookB {/*Style for lookB*/}
of course you can use more meaningful names.
Then you can add a class to each of the links that you need to use in this scenario like this:
<div id="tabs">
<div id="overview">
<a class="imagelink lookA" id="overviewtab" target="tabsa" href="toframe.html">Overviews</a>
</div>
<div id="gallery">
<a class="imagelink lookA" target="tabsa" href="tawagpinoygallery.html">Gallery</a>
</div>
<div id="reviews">
<a class="imagelink lookA" target="tabsa" href="trframe.html">Reviews</a>
</div>
</div>
So that each link can be refered to by its class, that is, imagelink. Also each link has a default lookA.
Now in jQuery (I know you did not specify jQuery but using it is 100 times simpler than plain Javascript).:
$(document).ready(function(){
$(".imagelink").click(function(){
$(".imagelink").removeClass("lookB");
$(this).addClass("lookB");
return true;
});
});
So on click on the link, it removes lookB from any other link and applies it only to the clicked link.
Hope this helps a bit.
I believe the selector is:
#gallery a:focus {...}
This is (inevitably) applied variably across browsers, however.
Stu Nicholls has a demo over on CSS Play, this demo being to remove the default outline of the focussed element, and otherwise style the clicked element.
Presumably this would be more reliably effected with jQuery, but it can be done with CSS.