Results 1 to 3 of 3

Thread: [RESOLVED] Width of the element to which jQuery Cycle is applied to

  1. #1

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Resolved [RESOLVED] Width of the element to which jQuery Cycle is applied to

    Hi guys

    In my site, there's a newsbox. It contains DIVs for each news. And I have specified the width of it to be 270px. But sometimes, the width is increased to 1024px, ie. the text inside it will be displayed as a single sentence.

    When I checked in Google, it was displayed as a single line at first. When I checked in Firefox, it was normally displayed. But when I refreshed Chrome again, this was fixed. Yesterday also, it was like so.

    Here's the link to the site: www.akhileshbc.com
    Top-right side contains the newsbox.

    Code:
    html Code:
    1. <!-- News box -->
    2.             <div id="top_newsbox">
    3.                 <div id="news">
    4.                     <div id="top_news">
    5.                         <div class="msg">I have moved to a better server now :)</div>
    6.                         <div class="msg">My site is up and running. Only 2 pages were included at the moment(ie. HOME & CONTACT page). I'll finish the rest of the pages soon. Don't forget to visit my site later :)</div>
    7.                     </div>
    8.                 </div>
    9.             </div>

    Css:
    css Code:
    1. #top_newsbox
    2. {
    3.     float:right;
    4.     width:392px;
    5.     height:108px;
    6.     margin-top: 13px;
    7.     margin-right:20px;
    8.    
    9.     background-image: url(images/top_news_box.png);
    10.     background-repeat: no-repeat;
    11.    
    12.    
    13.     padding-top:15px;
    14. }
    15.  
    16. #top_newsbox #news
    17. {
    18.     margin-left: 105px;
    19.     width: 270px;
    20.     height: 75px;
    21.     font-size: 11px;
    22. }
    23.  
    24. #top_newsbox #news #top_news
    25. {
    26.     width: 270px;
    27.     height: 75px;
    28.    
    29.     /*border: 1px solid #000000;*/
    30.    
    31. }
    32. #top_newsbox #news #top_news .msg
    33. {
    34.     width: 270px;
    35.     line-height: 16px;
    36. }
    I have tried debugging it myself. The css above is copied from the playground. So, it might look a bit messy.

    Thanks in advance
    Last edited by akhileshbc; Feb 9th, 2012 at 12:00 PM. Reason: Grammar Mistakes :D

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Width of the element to which jQuery Cycle is applied to

    It may or may not be the cause of your problem, but you should load all stylesheets before any Javascript. The cycle() function seems to be overwriting your cascaded styles with an inline style attribute; this is probably unintentional, so my guess is that the CSS width isn't applied (sometimes) when it starts doing its thing, so it uses the unstyled width of the element (which is however long the text makes it).

    As an aside, you want CSS selectors to be as short as possible. ID attributes are unique (if you're authoring properly), so there shouldn't be any need to list them in hierarchy.

  3. #3

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Width of the element to which jQuery Cycle is applied to

    Thanks Samba, I have moved the styles above the JS. Now when I checked in Chrome, it seems working. Will try again to finalize that the issue is cleared.

    I thought, it would be the problem with div (with id) causing the problem. ie. I have applied margin-left attribute to place some pixels from the left. And when Cycle is applied to the div, it might be overwriting the styles to position it absolute and might have caused the conflict. So, I have wrapped another div around this for only assigning the margin-left attribute and the div inside it was assigned with the width and height property only.


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

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



Click Here to Expand Forum to Full Width