Neil1
06-01-2015, 01:26 PM
I am, just out of curiousity, trying to build a functional interactive website purely with CSS and a single page of html. This is purely for my own experimentation and education not for practical implementation so if it can't be done I don't need JS etc. workarounds, just a simple "No".
To give a multi-page look with navigation options I have a series of divs styled as follows:
div1{
position:absolute;
top:10px;
left:10px;
width:calc(100% - 140px);
height:0;
}
They are all positioned exactly the same so they occupy the same area, but (If I could get it to work!) don't show up as they have zero height.
Then I am giving them all before and after pseudo elements positioned outside the div in the space remaining to the right, (Will just show before as after overlays before to create a 3D button)
div1::before{
content:"";
position:absolute;
top:0px;
left:calc(100% + 20px);
width:100px
height:100px;
cursor:pointer;
}
Again all the same for each div, except for the top: which increases in increments of 110px the they form a column of buttons down the right hand side of the page.
Next in the html I am giving each div a tab index so :focus{ can be used.
<div class="div1" tabIndex="1"></div>
Then finally adding height to the divs in the on focus state.
div1:focus{
position:absolute;
top:10px;
left:10px;
width:calc(100% - 140px);
height:calc(100% - 20px);
}
With additional styling not listed for simplicity, eg transitions on everything and :hover / :focus effects on the psuedo elements the buttons look like links, light up on hover, and start looking like they stick up and like they are clicked down while focused. When all the content divs are empty, just using background colours / borders for the purpose of test it works fine with the div relating to whichever button is clicked sliding down from the top and sliding back up to be replaced with another when the next is clicked.
However as soon as I add content to any of the divs they expand to fit it in the 0 height state, height:0 and max-height:0 both get overridden, and anything like overflow:hidden or Opacity:0 also effect the psuedo elements and the 'buttons' disappear.
So what I am trying to find out is, is there anyway of forcing the height to remain at zero unless in focus so the divs contents are hidden, or any other way of making the content 'invisible' out of focus state, but without effecting ::before and ::after pseudo elements?
To give a multi-page look with navigation options I have a series of divs styled as follows:
div1{
position:absolute;
top:10px;
left:10px;
width:calc(100% - 140px);
height:0;
}
They are all positioned exactly the same so they occupy the same area, but (If I could get it to work!) don't show up as they have zero height.
Then I am giving them all before and after pseudo elements positioned outside the div in the space remaining to the right, (Will just show before as after overlays before to create a 3D button)
div1::before{
content:"";
position:absolute;
top:0px;
left:calc(100% + 20px);
width:100px
height:100px;
cursor:pointer;
}
Again all the same for each div, except for the top: which increases in increments of 110px the they form a column of buttons down the right hand side of the page.
Next in the html I am giving each div a tab index so :focus{ can be used.
<div class="div1" tabIndex="1"></div>
Then finally adding height to the divs in the on focus state.
div1:focus{
position:absolute;
top:10px;
left:10px;
width:calc(100% - 140px);
height:calc(100% - 20px);
}
With additional styling not listed for simplicity, eg transitions on everything and :hover / :focus effects on the psuedo elements the buttons look like links, light up on hover, and start looking like they stick up and like they are clicked down while focused. When all the content divs are empty, just using background colours / borders for the purpose of test it works fine with the div relating to whichever button is clicked sliding down from the top and sliding back up to be replaced with another when the next is clicked.
However as soon as I add content to any of the divs they expand to fit it in the 0 height state, height:0 and max-height:0 both get overridden, and anything like overflow:hidden or Opacity:0 also effect the psuedo elements and the 'buttons' disappear.
So what I am trying to find out is, is there anyway of forcing the height to remain at zero unless in focus so the divs contents are hidden, or any other way of making the content 'invisible' out of focus state, but without effecting ::before and ::after pseudo elements?