border around charecters

Discussion in 'CSS' started by kichus, Nov 7, 2007.

  1. #1
    How do I set a border around each character in a <td>.

    I have a td which prints paging(pagination) dynamically... I want a border around each number(which shows the number of pages)

    Thanks
     
    kichus, Nov 7, 2007 IP
  2. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #2
    Add an element around each number and give it a border. I would use a list/anchor combo...

    I like having big clickable buttons.
     
    soulscratch, Nov 7, 2007 IP
  3. deques

    deques Peon

    Messages:
    206
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    not 100% sure if this works

    td {border: 1px solid #000;}
    Code (markup):
     
    deques, Nov 8, 2007 IP
  4. kichus

    kichus Peon

    Messages:
    188
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    deques, your code give border to the <td> not to the charecter (in this case numbers) i have given to print inside the td.
    soulscratch, i don't know how to give ul, li tags to inisde the php code i have given.

    ---
    for ($i = 1; $i <= $pager->numPages; $i++) {
    echo " | ";
    if ($i == $page)
    echo "","$i";
    else
    echo "<a href=\"$url&page=$i\">$i</a>"; // the number gets printed here..
    }
    -------
     
    kichus, Nov 8, 2007 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    ... and this is why giving us the code FIRST is important - what you want is reasonably simple...

    
    echo '<ul class="pageList">';
    for ($i=1; $i<=$pager->numPages; $i++) { 
    	echo '<li>',(($i==$page) ? $i : '<a href="'.$url.'&page='.$i.'">'.$i.'</a>'),'</li>';
    }
    echo '</ul>';
    
    Code (markup):
    with the following CSS:

    .pageList {
    	list-style:none;
    }
    
    .pageList li {
    	/* include these two for older firefux/gecko versions */
    	display:-moz-inline-block;
    	display:-moz-inline-box;
    	/* and of course RoW */
    	display:inline-block;
    	border:1px solid #000;
    }
    Code (markup):
    In the php the use of single quote instead of double means A> you can use double quotes inside it without escaping them, and B> lower overhead because you are telling it NOT to waste time parsing the text. The inlined expression just makes it simpler as well.

    On the CSS side, setting to inline-block makes sure that the border actually shows top and bottom - a common 'affliction' when trying to put borders or backgrounds on an inline element. Another approach would be to float them, but that's frought with layout difficulties.

    Oh, and I'd probably play with putting some margins and padding on the LI.
     
    deathshadow, Nov 8, 2007 IP
  6. kichus

    kichus Peon

    Messages:
    188
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks deathshadow

    it worked as you said i made some changes to the css and got the result the way i wanted..
     
    kichus, Nov 8, 2007 IP