I am trying to implement some simple CSS into a difficult situation imo
I have an input field, that I want to check if it has text within so the label can go straight up like when is happening on focus.
The thing this that this page is build in Marketo and I do not have any access to HTML just the CSS.
And also I have to use only classes not IDs etc.
Also another thing I am trying to do, is to target the label “Country” again only using classes and try to not affect the rest fields.
I am not sure if this can be done.
Yes the input field that you are pointing is the one at the start of the page, I am referring to the one in the middle.
You could write something and then get off the focus and see what’s happening.
About the “Country” label, I want to be target without the ID that it is now, because this will change many times.
I have to do it using the classes that are available and not interfere with the other elements.
If you’re using a tool then the rendered output SHOULD be the same. If it’s not, go back and do it again, or at least look at how the one that works is build and replicate it with the other one.
As for the country, I’d ask you to again, be consistent. The rendered html for this section gives a class (chief–choice–label) to hook onto and style consistently.
Finding out how to consistently render the html in Marketo is key to keeping your sanity on styling. If the rendered html isn’t consistent, you’re never going to be able to style the pages without jumping through major hoops to do so, and you’re going to have issues with quirks.
I’m just curious, but why? It looks like the form is being built as that’s a test page, so how were the first sets (that work) built differently than the second sets (that don’t)? Why can’t they be built the same?
Then your developer is doing you no favors whatsoever. A text box should render the same way every time. A checkbox list should render the same way every time.
Perhaps @PaulOB has a trick up his sleeve but I’m going to have to bow out because as far as I can tell, the “placeholder” one is impossible to do without javascript based on the way it’s rendered. The label is first, and you can’t do a css selector on an element based on something that comes AFTER it. Before it, yes. After it, no.
The label on the checkbox list should be relatively straight forward - if the list is rendered the same way each time.
It is impossible to style the label without using placeholder:shown otherwise there is no permanence. At the moment that element is moved out of the way using :focus-within but that only applies while the element has focus. You would either need to use the placeholder technique and move the label html under the input or use JS to achieve this. There is no other way to have something permanently moved.
You can’t over-ride !important without using the same specificity and that means using an id. The only way would be to use the id from higher up like this.
I’ve used the for attribute (for=“country”) to target that specific label but the problem is that your use of for=“Country” is invalid anyway as it must match a single ID and you have no ID that matches.
I think you need to rethink this form as there are too many issues here