Hi,
Ive been away from CSS for a few years and it seems to have moved on greatly
But I’m now stuck.
I am building a ‘navbar’ type function to my page which will in effect be a filtering device to ensure only those items selected will display (though they’ll all display by default on page load).
So, on initial page load, they will all display and when something is selected, the displayed items will be restricted to the section selected.
Designed with a checkbox followed by the ‘label’, I want a checkmark to display when it has been clicked on.
I can’t seem to get the ::after (green checkmark) to display on the same line (and after), the checkbox and the label.
Questions:
How best should I make the ::after checkmark display on the same line as the label and checkbox?
which leads to me to wonder;
If I make the checkmark display instead of the checkbox (so I make it a ::before element), so that when the page loads, they are all green by default; how should the css look, to make sure that when an item is clicked on (eg kettles), its checkmark stays green (or is re-assigned green) whilst the others all turn grey?
When ‘Kettles’ is selected, I want to show clearly which selection they user has made by showing a green checkmark beside Kettles but changing all others, not selected to grey.
There may be more than one item selected in which case all selected items should be green and all others, grey.
– Refer horizontal position 100% from the left side to get the correct distance.
(It’s usually better to refer position to top and left edges of its parent in flow.)
– Level with adjacents in line: Remove the erroneous line-height declaration.
Try:
/* Icon */
.tab label::after {
position: absolute;
/* right: 0; */
top: 0;
left: 100%; /* instead of right:0 */
display: block;
width: 3em;
height: 3em;
/* line-height: 3; */ /* pushes the icon down */
text-align: center;
-webkit-transition: all .35s;
-o-transition: all .35s;
transition: all .35s;
}
Yes please, I’m all ears. Though I think I am almost doing it without positioning. Maybe I am confusing you with some of the redundant css being there. Only the first three accordion styles use positioning. I have set “display:none;” for all the others, I think.’ The “.tab_content input” css is where I reset positioning to initial to override the first three.
Sorry that I may have confused you. That part of the css is not used and I will remove it because its output is set to display:none, later in the css. I’m only using the ‘before’ css now.
One last question on this part… If I click on kettles (for example), is there a CSS way to change the colour of the checkmarks for the other items in that section of kitchen equipment? So with a grey checkmark by default (on page load), to the left of each of kettles, bins, tea-makers, utensils - I want to click kettles and for its checkmark to become green (it does that) but for all the others to become #ffffff; Is that possible in css or would I need to do it with JS?
I want to avoid confusion for users by ensuring they know which sections they have selected.