473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

UL List. Is this possible?

Hello,

I have the following list:

<ul id="parent" class="parent">
<li>
<img...
</li>
<ul id="child" class="child">
<li>Message 1</li>
<li>Message 2</li>
<li>Message 3</li>
</ul>
</ul>

I need to do the following:
1. The list items in Parent should appear side by side.
2. The list items in Child should appear on the same line
3. The image should appear centered vertical and horizontal.

Is this possible?
I have been following a few examples in http://css.maxdesign.com.au/index.htm
However, until now I wasn't able to make this work.

My Css is as follows:

..parent ul li
{
display: inline;
list-style-type: none;
}

..child ul li
{
display: block;
list-style-type: none;
}

Any idea of how to solve this?

Thanks,
Miguel

Jun 5 '07 #1
5 2159
shapper wrote:
Hello,

I have the following list:

<ul id="parent" class="parent">
<li>
<img...
</li>
<ul id="child" class="child">
<li>Message 1</li>
<li>Message 2</li>
<li>Message 3</li>
</ul>
</ul>
This markup is invalid. Did you check it?
The child ul can't be a direct child of the parent ul; it can only be a
child of a li. Or put another way, only list items can be children of ul
elements. Bad code =uncertain results.
>
I need to do the following:
1. The list items in Parent should appear side by side.
2. The list items in Child should appear on the same line
3. The image should appear centered vertical and horizontal.
#3: Centered between what and what? You just want the child list items
"down lower" (possibly off the screen) somewhere?
Is this possible?
I have been following a few examples in http://css.maxdesign.com.au/index.htm
However, until now I wasn't able to make this work.
Probably possible, whatever it is, but I don't have time to spend on it
tonight. :-(
>
My Css is as follows:

.parent ul li
{
display: inline;
list-style-type: none;
}

.child ul li
{
display: block;
list-style-type: none;
}
This rule won't help you, because it doesn't apply to any markup you've
mentioned so far. The rule is for any list items which are descendants
of any ul elements which are descendants of any elements with class
"child". You don't have any such classed elements (although you have an
*id* "child", which would be selected by #child in your CSS), and your
child-like element has no descendants which are ul's, although #child is
itself a ul.

HTH
--
John
Jun 6 '07 #2
On Jun 6, 1:12 am, John Hosking <J...@DELETE.Hosking.name.INVALID>
wrote:
shapper wrote:
Hello,
I have the following list:
<ul id="parent" class="parent">
<li>
<img...
</li>
<ul id="child" class="child">
<li>Message 1</li>
<li>Message 2</li>
<li>Message 3</li>
</ul>
</ul>

This markup is invalid. Did you check it?
The child ul can't be a direct child of the parent ul; it can only be a
child of a li. Or put another way, only list items can be children of ul
elements. Bad code =uncertain results.
I need to do the following:
1. The list items in Parent should appear side by side.
2. The list items in Child should appear on the same line
3. The image should appear centered vertical and horizontal.

#3: Centered between what and what? You just want the child list items
"down lower" (possibly off the screen) somewhere?
Is this possible?
I have been following a few examples inhttp://css.maxdesign.com.au/index.htm
However, until now I wasn't able to make this work.

Probably possible, whatever it is, but I don't have time to spend on it
tonight. :-(
My Css is as follows:
.parent ul li
{
display: inline;
list-style-type: none;
}
.child ul li
{
display: block;
list-style-type: none;
}

This rule won't help you, because it doesn't apply to any markup you've
mentioned so far. The rule is for any list items which are descendants
of any ul elements which are descendants of any elements with class
"child". You don't have any such classed elements (although you have an
*id* "child", which would be selected by #child in your CSS), and your
child-like element has no descendants which are ul's, although #child is
itself a ul.

HTH
--
John
Hi sorry,

I wrote the markup instead of copying it but yes I have the child ul
inside a li:

<ul id="parent" class="parent">
<li>
<img...
</li>
<li>
<ul id="child" class="child">
<li>Message 1</li>
<li>Message 2</li>
<li>Message 3</li>
</ul>
</li>
</ul>

Basically, I need to create something as follows, without using
tables:

< ---------------------------- 400 px --------------------------------
>
-----------------------------------------------------------------------------
| | Message 01
| Image | Message 02
| | Message 03
-----------------------------------------------------------------------------
< ---- 80 px ---->
I hope I explained it well.
The lines are just to help me to explain what I need to do.

Thanks,
Miguel

Jun 6 '07 #3
shapper wrote:
Basically, I need to create something as follows, without using
tables:

< ---------------------------- 400 px --------------------------------
-----------------------------------------------------------------------------
| | Message 01
| Image | Message 02
| | Message 03
-----------------------------------------------------------------------------
< ---- 80 px ---->
I hope I explained it well.
The lines are just to help me to explain what I need to do.
Well not a good idea to have text within a pixel constrained block
because if your enlarge the text it will not fit in the block, better to
use "em"s ... but anyway

div.pretty { width: 400px; }
div.pretty img: { float: left; margin: 0 .5em 0 0;}
div.pretty ul { margin: 0; padding: 0; list-style: none; }
<div class="pretty">
<img src="yourImg.jpg" width="80" height="?" alt="the pix">
<ul>
<li>Message 01</li>
<li>Message 02</li>
<li>Message 03</li>
</ul>
</div>

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jun 6 '07 #4
Scripsit shapper:
I wrote the markup instead of copying it
And now you know one reason why that was wrong. You still didn't post the
URL, and you quoted the entire message, probably to indicate (as usual) that
you did not read it comprehensively. It is thus not very probably that you
will actually learn from the discussions, but I cannot resist asking one
question:
<ul id="parent" class="parent">
<li>
<img...
</li>
<li>
<ul id="child" class="child">
<li>Message 1</li>
<li>Message 2</li>
<li>Message 3</li>
</ul>
</li>
</ul>
What could possibly be the real data that is _adequately_ marked up when it
is marked up as a list with two (2) items, the first one consisting of an
image only and the second one consisting of three pieces of text? In
particular, how is the image so comparable to the inner list that it is
properly written as the first item in a list where the inner list is the
second item?

If the outer list isn't really a list, you are creating some unnecessary
complications.
Basically, I need to create something as follows, without using
tables:
- -
< ---------------------------- 400 px --------------------------------
So you "need" to force horizontal scrolling when your page is viewed in a
window narrower than 400 pixels, and you "need" to restrict the width to 400
pixels, no matter what the font size is. What creates these "needs"?
I hope I explained it well.
You didn't.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jun 6 '07 #5
On 2007-06-06, shapper <md*****@gmail.comwrote:
On Jun 6, 1:12 am, John Hosking <J...@DELETE.Hosking.name.INVALID>
wrote:
>shapper wrote:
Hello,
I have the following list:
[...]
I need to do the following:
1. The list items in Parent should appear side by side.
2. The list items in Child should appear on the same line
3. The image should appear centered vertical and horizontal.
[...]
My Css is as follows:
.parent ul li
{
display: inline;
list-style-type: none;
}
.child ul li
{
display: block;
list-style-type: none;
}
[...]
><ul id="parent" class="parent">
<li>
<img...
</li>
<li>
<ul id="child" class="child">
<li>Message 1</li>
<li>Message 2</li>
<li>Message 3</li>
</ul>
</li>
</ul>

Basically, I need to create something as follows, without using
tables:

< ---------------------------- 400 px --------------------------------
>>
-----------------------------------------------------------------------------
| | Message 01
| Image | Message 02
| | Message 03
-----------------------------------------------------------------------------
< ---- 80 px ---->
I hope I explained it well.
The lines are just to help me to explain what I need to do.
If you really want that exact vertical alignment, and the heights of the
list and the image are "fluid", you will need to use a table (or
inline-block but that's not supported widely). One row, two cells, image
in the first one, <ulin the second one, vertical-align: middle set on
td and text-align: center set on the first td.

Just noticed you said "without using tables". You could use display:
table-cell and display: table-row; do you need it to work on IE?

The "no-tables" philosophy is not highly compatible with wanting things
like a lot of vertical centering and supporting IE.

If you can live without vertical centering just do it like this:

img
{
float: left;
}

li
{
display: block;
list-style-type: none;
}

<img src="flowers-100.png">
<ul id="child" class="child">
<li>Message 1</li>
<li>Message 2</li>
<li>Message 3</li>
</ul>

As Mr Korpela pointed out there's not much reason why the <imgneeds to
be inside a list-item.
Jun 6 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Simon | last post by:
Hi, I'm hoping you could show me examples of how a functional/declarative language could be used to consicely describe resticted subsets of elements. I'm looking for a 'specification' style...
3
by: abro | last post by:
Problem: A list contained in a div contains several items that are made of two parts: itemName and itemValue. ie: <div id="data"> <li>longtime1 <span> 1326 mins></span></li> <li>longtime2...
11
by: Craig Keightley | last post by:
I have a mysql database with a list of companies who supply specific products tblSuppliers (simplified) sID | sName | goodsRefs 1 | comp name | 1,2,3,4,5 2 | company 2 | 2,4
24
by: Robin Cole | last post by:
I'd like a code review if anyone has the time. The code implements a basic skip list library for generic use. I use the following header for debug macros: /* public.h - Public declarations and...
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
25
by: Markus Svilans | last post by:
Hi, There seems to be some functionality missing from the STL. I am iterating through a linked list (std::list) using a reverse iterator and attempting to erase certain items from the list. It...
4
by: Cedric Rogers | last post by:
I wasn't sure if I could do this. I believe I am stretching the capability of what generics can do for me but here goes. I have a generic delegate defined as public delegate bool...
8
by: Mir Nazim | last post by:
Hello, I need to write scripts in which I need to generate all posible unique combinations of an integer list. Lists are a minimum 12 elements in size with very large number of possible...
6
by: Amit Bhatia | last post by:
Hi, I am not sure if this belongs to this group. Anyway, my question is as follows: I have a list (STL list) whose elements are pairs of integers (STL pairs, say objects of class T). When I create...
5
by: major | last post by:
Hi all, I would like to store (and read) a list of structs into a file using c+ + (each struct contains integers and strings), and I'm wondering if it there is a method to do it at "high level", I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.