Despite receiving some feedback, the issue regarding width control of <input>
remains unresolved.
This particular problem pertains to a WordPress website, but can be replicated in a very basic manner.
Situation: I have created a CSS nested heading/text toggle system with a checkbox. The checkbox is hidden and functions correctly, except for the fact that I am unable to control its width. By default, it is about 14px wide - I need it to span the full width of the containing div, which I cannot seem to achieve. (The checkbox must overlay the following heading, hence the use of position: absolute;)
Although the actual checkbox itself cannot be resized, the clickable area can: my concern lies with the width of this clickable area.
The HTML structure on the WP page looks like this (some parts are shortened for brevity)
<div id="left-area">
<article id="post-399" class="et_pb_post ...">
<h1></h1>
<p class="post-meta"></p>
<div class="entry-content">
<div class="nested-toggle">
<input type="checkbox" checked="">
<h2>Heading</h2>
The theme's CSS styling on "left-area" assigns a width of 712px. However, when I set the width of the <input>
element to 100%, it ends up being 968px wide, which does not match the width of the <div id="left-area">
, but rather that of an outer container styled by div.container {...}
to have a width of 968px.
This behavior can be reproduced with the following simple example
<div class="leftside">
<input type="checkbox" checked><i></i>
<h2>a Heading</h2>
</div>
along with the corresponding styling
div.leftside {width:900px;}
input[type="checkbox"] {
position: absolute;
width: 50%;
}
All testing was done using Firefox (latest version) and the minimal example was verified on codepen.io.
I'm relatively new (again) to this; did I overlook something obvious?
What could be causing this issue, and how can I ensure the correct width for the <input>
element?
Thanks!
PS: Either Firefox or WordPress appears to automatically add </input>
after my <input>
; technically, this may be invalid HTML as it triggers an error during validation by W3C, but it doesn't seem to impact rendering.