473,466 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Aligning logo, icon, text, and selection box. Should be extremely easy, but..?

8 New Member
Sorry if this sounds like a dumbass newbie question. I'm getting crazy or something, but somehow I can't get this simple thing to work:

1. In general, how do I center text and/or images vertically?

2. How would I do a top bar with a logo on the left, and an icon + text + combobox (small form with one select item) on the right, all vertically centered to eachother?
Like this:



And with "how", I mean: how with proper html/css :)
Dec 31 '08 #1
7 6019
Dormilich
8,658 Recognized Expert Moderator Expert
one possibility (maybe not the best, but working):
Expand|Select|Wrap|Line Numbers
  1. <div style="border: 1px solid black;">
  2.     <img src="img1.png" alt="large img" width="50" height="100">
  3.     <span style="line-height: 100px; float: right;">
  4.         <img src="img2.png" alt="small img" width="20" height="20" style="vertical-align: middle;">
  5.         some text
  6.         <input type="radio"  style="vertical-align: middle;">
  7.     </span>
  8. </div>
  9.  
the basic trick is to to apply vertical-align to an inline element that determins the height of the container

note:
inline style only for demo, proper CSS belongs in a css file. (where you can simplify it a bit)

regards
Dec 31 '08 #2
Bram2
8 New Member
Thanks, that seems to be somewhat in the right direction!
But two problems arise:

1. The radiobutton thing appears below (outside) the container
(tested with Firefox and IE7, in Opera it looks OK)

2. When putting actual <form> and </form> tags around the input thing, it gets messed up even more :(
(it seems to enforce a linebreak before form or something, but I really need form tags to have that input thing actually do something)

Any suggestions how to overcome that?
Dec 31 '08 #3
drhowarddrfine
7,435 Recognized Expert Expert
vertical alignment is different with input elements because there is no padding and only the margin matters.
Dec 31 '08 #4
Dormilich
8,658 Recognized Expert Moderator Expert
it depends on the actual code.

- <form> is not allowed inside <span>
- float the big image left and the <span> right should render OK (tried FF)

regards
Dec 31 '08 #5
Bram2
8 New Member
@Dormilich
Ah thanks, never knew that :)
But I really need <form> tags to get the selection thing actually working. So do you know any other way (other than form inside span, I mean) to get that working?

- float the big image left and the <span> right should render OK (tried FF)
Are you sure? I just tried it here and although the span part and logo are no at the same height, it seems they're now *both* below the div... What used to be a black border is now a single black line above everything.

When I change the background color of body and the div, the div seems completely empty, and the images and stuff appear below it...?
Jan 2 '09 #6
Dormilich
8,658 Recognized Expert Moderator Expert
@Bram2
it's always good to know where to look that up (I use SELFHTML: HTML/XHTML / Referenz /HTML-Elementreferenz (german only, but you might get the info though (english version suspended))
@Bram2
put the <form> tags before and after the span.
@Bram2
yea, there's practically no content in the <div>. apply a height to the <div> (if you don't need the border or the background you may also omit the <div>).
Expand|Select|Wrap|Line Numbers
  1. // CSS
  2. #top {
  3.     border: 1px solid black; 
  4.     height: 150px;
  5. // add padding, margin to your liking
  6. }
  7. #left {
  8.     float: left; 
  9.     line-height: 150px;
  10. }
  11. #right {
  12.     float:right; 
  13.     line-height:150px;
  14. }
  15. #left *, #right * {
  16.     vertical-align: middle;
  17. }
  18.  
  19. // HTML
  20. maybe some text
  21. <form>
  22. <div id="top">
  23. <span id="left">
  24.     <img width="100" height="100">&nbsp; 
  25. // you need a character to align the image in FF
  26. </span>
  27. <span id="right">
  28.     <img width="50" height="50">
  29.     text
  30.     <input type="radio"> // might need small corrections
  31. </span>
  32. </div>
  33. and some more text
  34. </form>
Jan 2 '09 #7
Dormilich
8,658 Recognized Expert Moderator Expert
found an article about clearing floats with CSS (so the height property on div is not necessary): Clearing a float container without source markup
Jan 6 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

34
by: Brandon J. Van Every | last post by:
What do you think of this Python logo? http://pythonology.org/logos Good, bad, indifferent, love it, hate it? -- Cheers, www.indiegamedesign.com Brandon Van Every ...
14
by: Christopher Subich | last post by:
As a hobby project, I'm writing a MUD client -- this scratches an itch, and is also a good excuse to become familiar with the Python language. I have a conceptual handle on most of the...
21
by: Atanas Boev | last post by:
Is there any CSS way to make a <hr /> noshadow so I don't get the default 3D look in Netscape? I tried to use some border-bottom to make the line, but my "line" should be under text that is...
9
by: Wang, Jay | last post by:
Hello, all, I would like to enable some text between <SPAN url="http://www.testserver.com/">WORD TO BE DRAGGED </SPAN>. I put some javascript and it will extract http://www.testserver.com/ from...
3
by: Richard | last post by:
http://users.cjb.net/rsb01/screen001.jpg This is the logo image I speak of. If Mozilla is opensource stuff, why is the windows logo attached here? The logo is a registered trademark of M$.
2
by: Tim Marshall | last post by:
Access 2003. The situation is this: I have a "criteria selection form" in which there are a many different criteria, mostly displayed as combo and text boxes in which a user can enter stuff,...
3
by: Woody Splawn | last post by:
Does anyone know where I can find an under construction logo or icon?
1
by: Linux Boy via .NET 247 | last post by:
(Type your message here) Hi everyone, I would like to ask a question about aligning text within one label. I have an application that everytime the user click on Enter Record button, they will...
2
by: John | last post by:
Hi I need to right justify amounts in a field with width of x digits. I have tried Format(2.35, "##########0.00") but the numbers come out left justified. Anyway to justify them on the right...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.