This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to hide a div with jQuery?
Is there any way to hide the content of div in css without using the display: none;
because it remove the object from code.
I also used the visibility: hidden;
but the image content of div still display
Place the contents inside of a inner div and set that inner div to display none.
Set visibility to hidden and don't set the visibility of the descendants (the images that are showing up) to visible.
with jQuery you can do
$('div').hide();
If you want to be more specific you can use an id or class name instead if div.
ex: $('#myid').hide();
You can store the contents in temporary and then do empty, restore these content to the DIV when you need.
var contents= $('divId').html();
$('divId').html('');
Related
This question already has answers here:
Transitions on the CSS display property
(37 answers)
Closed 2 years ago.
How to add a fade-in effect when clicking on a div. I have a profile menu dropdown and the click event was made with jQuery. Also, how to make this to close if I click anywhere outside?
This is the code
jQuery(document).ready(function(){
jQuery(".profile_link_header").click(function(){
jQuery(".dropdown").toggleClass("active");
})
});
CSS
.dropdown.active{
display: block;
}
Without your html code, you just add fade-in on your selector:
$(document).ready(function(){
$(".profile_link_header").click(function(){
$(".dropdown").toggleClass("active").fadeIn("slow");;
})
});
I suppose here is on your .dropdown class, else you apply the faeIn on your selector desired
This question already has answers here:
offsetting an html anchor to adjust for fixed header [duplicate]
(28 answers)
Closed 6 years ago.
So I have successfully gotten my page to jump to different sections on the page via buttons referencing the ID's like this
<button id="niftyBtn">Things</button></br>
<div id="nifty">Blah</div>
I have several of those and they all go to the correct portion of the page.
The problem is, there is a fixed nav that is included into the page that I can't change and the top of the sections are going behind that navbar instead of below it.
I have tried to use several different variations of a jquery solution I saw using .offset() but none of them have been effective. Any input is appreciated
Note: It behaves the exact same way when I use jQuery or javascript to jump the sections instead of href tags.
You don't need a javascript solution, something as simple as this will do:
h2:before,h3:before,h4:before {
content: " ";
display: block;
visibility: hidden;
margin-top: -7em;
height: 7em;
}
Granted, these are meant for headings, but you can substitute with a class, or IDs for the same effect. The measurements will have to be amended, of course.
BTW, why are you using <button> to wrap an <a>? That code should just be Things</br> and if you want it to look like a button, style it like a button.
This question already has answers here:
How can I remove a style added with .css() function?
(21 answers)
Closed 6 years ago.
Let's say I have a div.foo with this CSS:
.foo {
height: 70vh;
}
And I change the height of div.foo with jQuery like this:
$('.foo').height(100);
How do I reset the CSS of div.foo so its height is rendered 70vh again?
One solution that works is to reload the entire CSS file this way. But I wonder if there is a solution to only reset the CSS of div.foo, not the entire stylesheet?
With jQuery, you are adding your styles to the style attribute of the element. It is removed again, if you call the function again with an empty string (""). This will remove the property in the style attribute.
If you have e.g. this command:
$('.foo').css('height', '100px');
You can revoke it by
$('.foo').css('height', '');
See also the discussion here: https://stackoverflow.com/a/4036868/3233827
$('.foo).height(''); should be sufficient to erase the style applied by jQuery
You can remove the style attribute from the element. This attribute holds any dynamic styles.
$('.foo').css('background', 'teal');
$('#reset').click(function() {
$('.foo').removeAttr('style');
});
.foo {
height:100px;
width:100px;
background:red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<div class="foo"></div>
<p><button id="reset">Reset style</button></p>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
The community reviewed whether to reopen this question 9 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I am trying to hide an HTML element with CSS.
<select id="tinynav1" class="tinynav tinynav1">
but it's very resilient, even with the Google Inspect element I cannot change the styling.
It's simple, just set the display property to none in CSS:
#tinynav1
{
display:none
}
again when you would like to show it set the display to block.
visibility: hidden hides the element, but it still takes up space in the layout.
display: none removes the element completely from the document. It does not take up any space, even though the HTML for it is still in the source code.
Other advantages of using display:
display:none means that the element in question will not appear on the page at all (although you can still interact with it through the DOM). There will be no space allocated for it between the other elements.
visibility:hidden means that unlike display:none, the element is not visible, but space is allocated for it on the page.
use display:none; or visibility:hidden;
CSS:
select#tinynav1 { display: none; }
or if multiple selects should be hidden, use the corresponding class:
select.tinynav1 { display: none; }
As inline-style you could do it also (which you can try for inspector):
<select id="tinynav1" style="display: none">
You can use display:none or visibility:hidden, based on your requirements:
#tinynav{display:none;}
or
#tinynav{visibility:hidden;}
Refer the below URL for better understanding of display:none and visibility:hidden.
Difference between "display:none" and "visibility:hidden"
If you want to hide it and collapse the space it would need, use display: none; if you want to keep the space, use visibility: hidden.
<select id="tinynav1" class="tinynav tinynav1">
CSS
.tinynav {
display: none;
}
Use style="display:none" directly on the <select> or create a css class having that setting and assign the class to the <select>.
Use this CSS
.tinynav {
display: none;
}
or
.tinynav {
visibility: hidden;
}
The difference is that the former will make the select not rendered at all and the latter will make the select rendered (it will take the space of the document) but it will be completely invisible;
Here's a fiddle to show the difference: http://jsfiddle.net/rdGgn/2/
You should notice an empty space before the text in third line. It is the select that is rendered but not visible. There is no space before the second line of text, because the select is'nt rendered at all (it has display:none).
There is also a third option which is
.tinynav {
opacity: 0;
}
It behaves almost the same as visibility: hidden but the only difference is that with opacity: 0 you can still click the select. With visibility: hidden it is disabled.
This question already has answers here:
Hiding the scroll bar on an HTML page
(22 answers)
Closed 9 years ago.
Is it possible to hide the browser's horizontal and vertical scroll through HTML or Javascript?
I have a listing and for that I have made my own div to div scroller and I want to hide the browser's scroll bars
Thanks in advance
You can apply overflow: hidden to html and/or body in CSS but then, of course, you have to be careful so that your <div> doesn't expand past the browser window.
Example:
html, body
{
overflow: hidden;
}
Set the body tag to overflow: hidden;.
You should be able to set the css for the div to hide the scrollbar. Put everything into a main div and set the css for the main div to this:
height: 100%;
width: 100%;
overflow:hidden;
then use your own scrollbars on the content div.