I've noticed that any modification of the <code>
's style with respect to its width doesn't have any effect. It's seems to always be set to "auto".
I'm just trying to have some code written inside a <code>
tag (this tag is mandatory due to some known iBooks bugs) that has 100% width. One workaround is to put the <code>
inside a <div>
which has a 100% background style. This works OK but I'll have to deal with a couple of hundred <code>
tags... This is the reason I would prefer just to be able to modify the <code>
's width.
Any thoughts? Thanks.
To convert it to a fixed-width layout, simply add a fixed with to the #wrapper and set the margins to auto. Setting the margins to auto will cause the left and right margins to be equal no matter how wide the browser window is, which will cause your fixed-width layout to be positioned in the center of the browser.
In HTML, you can use the width attribute to set the width of an element. Alternatively, you can also use the size attribute to define the width of the <input> .
The width attribute specifies the width of the element, in pixels. Note: For input elements, the width attribute is used only with <input type="image"> .
Add a display: block
or inline-block
as per your requirement to the code
element. Rest should work as planned
See an example
<code>
elements are inline elements. Setting a height or width on these do not have any effect on their size.
Use display:inline-block
::
code {
display: inline-block;
width: 100px; /* Whatever. The <code>'s width will change */
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With