Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Jun 2006
    Posts
    18
    Plugin Contributions
    0

    Default CSS Buttons and fixed width

    Here:

    http://www.zen-cart.com/wiki/index.p..._-_CSS_Buttons

    you can find this:

    Style
    For an unknown reason, Zen Cart™ appears to calculate the number of characters in a button's value and then generates a length in pixels based on the size of the value. Would it not be wiser to allow the button to choose its own size?
    If you know why a width is applied to CSS Buttons please share, it would also be great to be able to disable this feature.

    Does anyone know how to make fixed width of a button? I want to make background image (see atachment) but I dont know how to... another way would be to stretch the background image but I guess it is not possible either...
    Attached Images Attached Images  

  2. #2
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: CSS Buttons and fixed width

    Hi CzechBoy,

    the Zen css-buttons code is based on some code I wrote as a contribution. The reason I added the automatic width calculation is because I could not find any other (practicle) way to create buttons that adjusted automaticly to the width of the text. (one way that works across browsers is wrapping each button in a table, but that would obviously (?) not be an improvement).

    If anyone knows a better way to create css buttons (i.c.w. the current Zen Code of course) that adjust automaticly to the containing text please tell! It would not suprise me if a better solution exists, and I just overlooked it at the time i wrote it.

    The change all buttons to the same fixed width you can add this at the bottom of the stylesheet_css_buttons.css file:
    Code:
    .cssButton, .cssButtonHover{
    width: 200px !important;
    }

  3. #3
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: CSS Buttons and fixed width

    Or, depending on the way you defined other sizes, maybe better use em's:
    Code:
    .cssButton, .cssButtonHover{
    width: 15em !important;
    }
    (of course you need to change the value toyour needs).

    And another note about the automatic width problem: please don't forget that it needs to work for the links as well as the inputs (and needs to work in the different major browsers too of course). In the past, several people suggested solutions that worked on the links, to find out later that it did not work for the inputs.

  4. #4
    Join Date
    Jun 2006
    Posts
    18
    Plugin Contributions
    0

    Default Re: CSS Buttons and fixed width

    I see.. quite problematic task (better to have variable width ;) )... from what I see, the best solution for now would be image buttons To have an image for each border as it is in case of vertical boxes it is not possible, right? It would be solution as well...

  5. #5
    Join Date
    Jun 2006
    Posts
    18
    Plugin Contributions
    0

    Default Re: CSS Buttons and fixed width

    Well with the border image it is nonsense right?:) But anyway is there a way how to create a similar CSS button to mine from the previous message?

  6. #6
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: CSS Buttons and fixed width

    I am afraid I do not have an "out of the box" solution for you. But I think there are lots of ways to achieve what you want.

    *You could revert to graphical buttons and create individual graphical buttuns for each case.

    *Or you can use fixed sized css buttons and use your image as background.

    *Or you can split the image in three parts and modify the button code so that you have: a fixed sized left box+left part(background)image, and a fluid middle box with text+repeating background middleimage and fixed sized right box with the right part of your image. All glued together of course so that it looks like one.

    hth

  7. #7
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: CSS Buttons and fixed width

    You might also look to the css sliding door code to create a fluid button style.
    Zen-Venom Get Bitten

  8. #8
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: CSS Buttons and fixed width

    Quote Originally Posted by kobra
    You might also look to the css sliding door code to create a fluid button style.
    Interesting :-)

    If that technique works in the Zen Cart case, it will enable us to have cool graphical css buttons, without adding (too much) markup.

  9. #9
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: CSS Buttons and fixed width

    Funny,

    the article I just read about the css sliding door technique might also contain a solution to the automatic width problem.

    In most browsers, floating an element will act sort of like shrink-wrapping it — it gets shrunk to the smallest possible size of the contents it contains. If a floated element contains (or is) an image, the float will shrink to the width of the image. If it contains only text, the float will shrink to the width of the longest non-wrapping line of text.
    I am quite sure I did not try that the time, so it might be a better solution than the current calculated width.

    Source: http://alistapart.com/articles/slidingdoors/

    (under "One Hack for Consistency")

  10. #10
    Join Date
    Nov 2003
    Posts
    1,987
    Plugin Contributions
    15

    Default Re: CSS Buttons and fixed width

    It works! I removed the width setting

    Not using the float, because of course that did not help setting the input width in IE correctly. IE adds some magic padding to every input which is not over ridable setting the padding using css.

    But it inpired me to look into it further and I found a trick to fix the input width in IE after all.

    It does require a IE specific stylesheet or a a little hack to be added. Both are *very* easy to implement though (maybe the hack is a little easier because IE specific stylesheet probably needs some code changes in the zen core).

    Here is a (temporary!) example online which uses the hack: http://www.beterelektro.nl/test/css-button/index.html

    edit:
    found the idea here: http://www.brownbatterystudios.com/s...x/#comment-196

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. CSS Buttons Width Setting
    By PortraitArtist in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 10 Jan 2011, 10:39 PM
  2. Banners width and height fixed
    By jibon in forum Basic Configuration
    Replies: 5
    Last Post: 14 May 2009, 06:53 AM
  3. fixed width page, categories and currencies help
    By nonfinite in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 23 Apr 2009, 08:19 PM
  4. CSS buttons - why is width limited?
    By daymobrew in forum General Questions
    Replies: 2
    Last Post: 4 Apr 2009, 12:49 AM
  5. css buttons width - can't find where to adjust
    By cupcake in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 13 May 2007, 12:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg