html - CSS DIV Swap without fixed height? -
I'm curious if it is possible to get simple div swap using CSS, if there is no fixed height in the divi Looking for a pragmatic answer to the answer and come up with some concrete discussion on this matter.
In this view, a huge beer list is to be divided into four separate divs and one time to display only one of them. When clicking on the associated anchor, the displayed division will switch when hiding the other three, the first division should be displayed when the page is loaded. With this I have a little experience and success, but with only certain sizes, all the other devices behind it will be hidden in the form of the leading diva.
These special devices will include formatted tables and unordered lists, I'm not sure there will be any impact on it, but thought that it is worth mentioning only in the case. There can not be a fixed height of the division because the number of items in each will be different I have not coded it yet because I'm not sure that it is worth investing on time, but the HTML looks like this:
& lt; Div id = "secondaryNav" & gt; & Lt; Ul & gt; & Lt; Li & gt; Link div1 & lt; / Li & gt; & Lt; Li & gt; Link div2 & lt; / Li & gt; & Lt; Li & gt; Link div3 & lt; / Li & gt; & Lt; Li & gt; Link Div4 & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; & Lt; Div id = "swappedcontent" & gt; & Lt; Div id = "1" & gt; & Lt; Table & gt; & Lt; TR & gt; Content & lt; / TR & gt; X 40-50 & lt; / Table & gt; & Lt; / Div & gt; & Lt; Div id = "2" & gt; & Lt; Table & gt; & Lt; TR & gt; Content & lt; / TR & gt; X 40-50 & lt; / Table & gt; & Lt; / Div & gt; & Lt; Div id = "3" & gt; & Lt; Table & gt; & Lt; TR & gt; Content & lt; / TR & gt; X 40-50 & lt; / Table & gt; & Lt; / Div & gt; & Lt; Div id = "4" & gt; & Lt; Table & gt; & Lt; TR & gt; Content & lt; / TR & gt; X 40-50 & lt; / Table & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - swappedContent - & gt; I have found an example that I am modeling after this layout (which uses javascript), but the reason for linking to this site is not guaranteed to me here If I have to link it to clarity, please let me know.
CSS "display" In each device:
& lt; Div id = "myDiv" style = "display: none;" & Gt; And then when you want to display the div, javascript in the following:
document.getElementById ("myDiv"). Style.display = "block"; Finally, you will have something like this:
& lt; Div id = "secondaryNav" & gt; & Lt; A href = "javascript: void (0)" onclick = "showDiv ('1')" & gt; Link div1 & lt; / A & gt; & Lt; A href = "javascript: void (0)" onclick = "showDiv ('2')" & gt; Link div2 & lt; / A & gt; & Lt; A href = "javascript: void (0)" onclick = "showDiv ('3')" & gt; Link div3 & lt; / A & gt; & Lt; A href = "javascript: void (0)" onclick = "showDiv ('4')" & gt; Link Div4 & lt; / A & gt; & Lt; / Div & gt; & Lt; Div id = "swappedcontent" & gt; & Lt; Div id = "1" & gt; & Lt; Table & gt; & Lt; TR & gt; Content & lt; / TR & gt; X 40-50 & lt; / Table & gt; & Lt; / Div & gt; & Lt; Div id = "2" style = "display: none;" & Gt; & Lt; Table & gt; & Lt; TR & gt; Content & lt; / TR & gt; X 40-50 & lt; / Table & gt; & Lt; / Div & gt; & Lt; Div id = "3" style = "display: none;" & Gt; & Lt; Table & gt; & Lt; TR & gt; Content & lt; / TR & gt; X 40-50 & lt; / Table & gt; & Lt; / Div & gt; & Lt; Div id = "4" style = "display: none;" & Gt; & Lt; Table & gt; & Lt; TR & gt; Content & lt; / TR & gt; X 40-50 & lt; / Table & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; Function show divi (divId) {for (i = 1; i & lt; = 4; i ++) {document.getElementById (i) .style.display = "none"; } Document.getElementById (divId) .style.display = "block"; } & Lt; / Script & gt; Note: Make sure to place the script in an appropriate location (usually in the element).
Comments
Post a Comment