/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] – Not resolved: Float issues (- cache didn’t want to clear)

Hi (or however one starts these things),

I’ve been trying to ‘style’ the input (text) tags in an HTML form.
This has been successful by doing the following:

[code=html]
<span class=’inputleft’>
<input class=’input_styled’ type=’text’ />
<a class=’inputright’></a>
</span>
[/code]

CSS

[code]
input.input_styled {
background:url(/library/images/input_middle.png) repeat-x top left;
float: left;
padding-top: 2px;
padding-bottom: 2px;
height: 16px;
}
span.inputleft {
padding-left: 5px;
height: auto;
width: auto;
float:left;
background: url(/library/images/input_left.png) no-repeat 0px 0px;
}
a.inputright {
height: auto;
width: auto;
background: url(/library/images/input_right.png) no-repeat top right;
padding-left: 11px;
padding-top: 18px;
float: left;
cursor: pointer;
}
[/code]

…This works, by the way.

What is annoying, however, is that I don’t want the parent <span> (inputleft) to be floated because that could, potentially, interfere with my page layout. Nor do I want to have to put dividers (which clear:all) in appropriate places since the styling et cetera is done with javascript to normal input tags.

When I remove the “float:left” property from the parent <span> tag, I can no longer see its background image anymore, which makes the whole effect pointless. I don’t understand why it does this because it still has the padding-left value, which should (surely!) push the <input> element 5px to the right and make the thing visible again, no?

Any help would be much appreciated.

to post a comment
CSS

14 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 18.2009 — Why float any of the elements? They are all inline elements.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 18.2009 — This is a good point. I found a solution by just placing them in a <div> tag but it seemed an unnecessary cluttering of the source.

Thanks.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 18.2009 — Removing the float property does something even more bizarre, here's a (before and after) pair of screenshots.

[upl-file uuid=2beb8e62-2357-4a15-80cc-e7c386adc210 size=5kB]before.png[/upl-file]

[upl-file uuid=cf3157f5-0064-420c-acd0-5c77a6d49083 size=5kB]after.png[/upl-file]
Copy linkTweet thisAlerts:
@FangMay 18.2009 — Remove this: [I]padding-top: 18px;[/I]
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 18.2009 — The structure has changed: it's now:

[code=html]
<span id='wrapper'>
<span id='lhs' class='inputleft'></span>
<input id='input' class='input_styled' />
<a class='inputright' id='rhs' />
</span>
[/code]

CSS:
[CODE]
input.input_styled {
float: left;
font-style: normal;
font-weight: normal;
font-size: 9pt;
font-variant: normal;
background:url(/library/images/input_middle.png) repeat-x top left;
padding-top: 2px;
padding-bottom: 2px;
border: none;
height: 16px;
outline: none;
color: #000945;
}
span.inputleft {
padding-top: 18px;
float: left;
padding-left: 5px;
overflow: hidden;
background: url(/library/images/input_left.png) 0px 0px no-repeat;
}
a.inputright {
float: left;
height: auto;
width: auto;
background: url(/library/images/input_right.png) no-repeat top right;
padding-left: 11px;
padding-top: 18px;
cursor: pointer;
}
[/CODE]


-the wrapper span has no styling
Copy linkTweet thisAlerts:
@FangMay 19.2009 — a.inputright {
float: left;
height: auto;
width: auto;
background: url(/library/images/input_right.png) no-repeat top right;
padding-left: 11px;
[COLOR="Red"]padding-top: 18px;[/COLOR]
cursor: pointer;
}
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 19.2009 — Oh I see, I think... I assume that the top-padding removes it from being in-line with the other elements?

I can't try it now, alas, because my computer has gone in for repair. I shall do next week and get back to you then. Thank you for the help so far.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 26.2009 — I tried that, the code now reads:

[CODE]
input.input_styled {

font-style: normal;
font-weight: normal;
font-size: 9pt;
font-variant: normal;
background:url(/library/images/input_middle.png) repeat-x top left;
padding-top: 2px;
padding-bottom: 2px;
border: none;
height: 16px;
outline: none;
color: #000945;
}
span.inputleft {
padding-top: 18px;

padding-left: 5px;
overflow: hidden;
background: url(/library/images/input_left.png) 0px 0px no-repeat;
}
a.inputright {

height: auto;
width: auto;
background: url(/library/images/input_right.png) no-repeat top right;
padding-left: 11px;

cursor: pointer;
}
[/CODE]


The output is in the attached image (it doesn't seem to work).

Thanks for your help so far in this.

[upl-file uuid=c744007d-31aa-4069-9403-f3b03c633474 size=6kB]Picture 2.png[/upl-file]
Copy linkTweet thisAlerts:
@FangMay 27.2009 — Without the images it's impossible to see what is wrong.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 28.2009 — Oh. I posted the "how it's supposed to look" before. I'll do so again.

It looks correct with the following css:
[CODE]
input.input_styled {
float:left;
font-style: normal;
font-weight: normal;
font-size: 9pt;
font-variant: normal;
background:url(/library/images/input_middle.png) repeat-x top left;
padding-top: 2px;
padding-bottom: 2px;
border: none;
height: 16px;
outline: none;
color: #000945;
}
span.inputleft {
padding-top: 18px;
float: left;
padding-left: 5px;
overflow: hidden;
background: url(/library/images/input_left.png) 0px 0px no-repeat;
}
a.inputright {
float: left;
height: auto;
width: auto;
background: url(/library/images/input_right.png) no-repeat top right;
padding-left: 11px;
padding-top: 18px;
cursor: pointer;
}
[/CODE]


If I take out floats and (as per your suggestion) remove the padding-top from the input_right anchor (the code is as follows):

[CODE]
input.input_styled {

font-style: normal;
font-weight: normal;
font-size: 9pt;
font-variant: normal;
background:url(/library/images/input_middle.png) repeat-x top left;
padding-top: 2px;
padding-bottom: 2px;
border: none;
height: 16px;
outline: none;
color: #000945;
}
span.inputleft {
padding-top: 18px;

padding-left: 5px;
overflow: hidden;
background: url(/library/images/input_left.png) 0px 0px no-repeat;
}
a.inputright {

height: auto;
width: auto;
background: url(/library/images/input_right.png) no-repeat top right;
padding-left: 11px;

cursor: pointer;
}
[/CODE]


The HTML structure is as follows:
[code=html]
<span id='t1_wrapper'>
<span class='inputleft' id='t1_lhs'></span>
<input id='t1' class='input_styled' type='text' />
<a class='inputright' id='t1_rhs'></a>
</span>
[/code]


Cheers.

[upl-file uuid=0a4859b4-d00f-47ea-becc-266eb1c778bd size=5kB]correct.png[/upl-file]

[upl-file uuid=f2b83387-5e36-48cf-b443-aac50ea03468 size=5kB]incorrect.png[/upl-file]
Copy linkTweet thisAlerts:
@FangMay 28.2009 — The actual background images you are using. If I use my images it works correctly.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 28.2009 — Oh right. Okay, here they are:

[upl-file uuid=dcbf7b02-f9ca-43aa-b885-4c7bc978e06f size=312B]input_left.png[/upl-file]

[upl-file uuid=e27d22eb-5bd9-46ca-804b-c31905a665a6 size=152B]input_middle.png[/upl-file]

[upl-file uuid=a9f6f7aa-8a5c-45d3-ad5f-8f3fe9b9afe6 size=649B]input_right.png[/upl-file]
Copy linkTweet thisAlerts:
@FangMay 29.2009 — Changes to html & css&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;background image alignment&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;style type="text/css"&gt;
#t1_wrapper * {float:left;}
input.input_styled {
font-style: normal;
font-weight: normal;
font-size: 9pt;
font-variant: normal;
background:url(/library/images/input_middle.png) repeat-x;
border: none;
height: 18px;
outline: none;
color: #000945;
}
span.inputleft {
height: 18px;
width: 5px;
background: url(/library/images/input_left.png) no-repeat;
}
a.inputright {
width: 11px;
height:18px;
background: url(/library/images/input_right.png) no-repeat;
cursor: pointer;
}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;span id="t1_wrapper"&gt;
&lt;span class="inputleft" id="t1_lhs"&gt;&amp;nbsp;&lt;/span&gt;
&lt;input id="t1" class="input_styled" type="text"&gt;
&lt;a class="inputright" id="t1_rhs"&gt;&amp;nbsp;&lt;/a&gt;
&lt;/span&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 29.2009 — Thank y' kindly sirrah.

No, in all seriousness, thank you very much, that would appear to work.
×

Success!

Help @blue-eye-labs spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...