Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-28-2010, 09:54 AM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default DIV instead of TABLE is still a bit new to me...

So I'm trying to figure out a few of the quirks in CSS code... Lets say I have the following code:
Code:
<div class="block" id="recentvideo">
  <h2 class="blockhead">Recently Uploaded Media</h2>
  <div class="blockbody floatcontainer" style="background: #F2F6F8 none;">
    <ul id="latestmediacontainer" style="padding: 20px 0px 0px 0px;">
      <li style="-webkit-box-shadow: #C8C8C8 -2px 2px 2px;
        background: white none; border: 1px solid #E9E9E9;
        display: block; float: left; padding: 10px;
        text-align: center; margin: 0px 0px 20px 20px;
        height: 200px; width: 300px;">testing....</li>
      <li style="-webkit-box-shadow: #C8C8C8 -2px 2px 2px;
        background: white none; border: 1px solid #E9E9E9;
        display: block; float: left; padding: 10px;
        text-align: center; margin: 0px 0px 20px 20px;
        height: 200px; width: 300px;">testing....</li>
    </ul>
  </div>
</div>
Gives the following output:


However, I would like these two <LI> fields to stretch to 50% each, so it fills out the entire division. So I changed the width of the two <LI> fields to 50%, instead of 300px. Unfortunately this didn't work and instead gave me thus:


It looks like it is doing this because 50% isn't 50% of the remaining space, but 50% of the entire space of the division, BEFORE space is removed for padding, margins, dropshadows and borders. This is evident because if I change the width of the <LI> fields to 100%, I get the following:


So my question of course is... How do I put a percentage width in place that calculates based on the remaining space available?
Attached Images
File Type: png Untitled-2.png (4.0 KB, 0 views)
File Type: png Untitled-3.png (5.5 KB, 0 views)
File Type: png Untitled-4.png (3.9 KB, 0 views)
Reply With Quote
  #2  
Old 03-28-2010, 02:21 PM
bananalive bananalive is offline
 
Join Date: Oct 2007
Location: UK
Posts: 2,802
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

An easy way around it would be have the width of the one of the right as 50% and then have the one on the left not floating but aligned to left.
Reply With Quote
  #3  
Old 03-28-2010, 03:00 PM
Wayne Luke's Avatar
Wayne Luke Wayne Luke is offline
Senior Member
 
Join Date: Jan 2002
Location: Southern California
Posts: 1,694
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Set your width to 48% and center them within the DIV. Or remove the margins and box shadows.

http://www.w3schools.com/CSS/css_boxmodel.asp
Reply With Quote
  #4  
Old 03-28-2010, 05:13 PM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Wayne Luke View Post
Set your width to 48% and center them within the DIV. Or remove the margins and box shadows.

http://www.w3schools.com/CSS/css_boxmodel.asp
Yeah, but I want the page to look like the rest of the VB Skin. I'm going for consistancy and uniformity here. So removing the margins and box shadows is not an option. Also, setting the width to 48% is also not an option, as its different between everyone's different resolutions. On some computers, 48% is not enough, while 45% would be too much on other computers.

As well, I want to program it into my mod so people can select between 100% (1 per row), 50% (2 per row), 33.3% (3 per row) and 25% (4 per row) width of each cell. While a solution like this would be simple with a table and the "cellspacing" parameter, it seems that CSS makes this a bit complicated.
Reply With Quote
  #5  
Old 03-28-2010, 07:20 PM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay... I'm just going to accept that you can't do percentages properly with the box model... an inherint flaw of design... and move on from it... however, now I have a new issue...

Using the following code: (I added padding and borders so its easier to see...)
Code:
	<li style="-webkit-box-shadow: #C8C8C8 -2px 2px 2px; background: white none; border: 1px solid #E9E9E9; display: block; float: left; padding: 10px; margin: 20px 0px 0px 20px; width: 500px; text-align: center;">
		<div>
			<div style="padding: 10px; border: 1px solid #000000; float: left;">
				<a href="media.php?{vb:raw session.sessionurl}mediaid={vb:raw mediaID}"><img src="{vb:raw thumbnail}" border="0" alt="{vb:raw title}" width="150" /></a>
			</div>
			<div style="padding: 10px; border: 1px solid #000000;">
				<a href="media.php?{vb:raw session.sessionurl}mediaid={vb:raw mediaID}">{vb:raw title}</a><br />
				{vb:raw date} at <span class="time">{vb:raw time}</span> by {vb:raw username}<br /><br />
				<img src="{vb:stylevar imgdir_rating}/rating-trans-15_{vb:raw rating}.png" alt="Rating: {vb:raw rating}" />
			</div>
		</div>
		<div style="padding: 10px; border: 1px solid #000000;">
			{vb:var preview}
		</div>
		<div style="padding: 10px; border: 1px solid #000000;">
			Tags:
		</div>
	</li>
I get the following:


How would I change the code so I get the following instead?
Attached Images
File Type: png Untitled-5.png (39.3 KB, 0 views)
File Type: png Untitled-6.png (38.8 KB, 0 views)
Reply With Quote
  #6  
Old 03-28-2010, 08:46 PM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Figured it out...

Code:
<li style="-webkit-box-shadow: #C8C8C8 -2px 2px 2px; background: white none; border: 1px solid #E9E9E9; display: block; float: left; padding: 10px; margin: 20px 0px 0px 20px; text-align: center; width: 500px;">
	<div style="display: table;">
		<div style="display: table-row;">
			<div style="display: table-cell; padding-right: 10px;">
				<a href="media.php?{vb:raw session.sessionurl}mediaid={vb:raw mediaID}"><img src="{vb:raw thumbnail}" border="0" alt="{vb:raw title}" width="150" /></a>
			</div>
			<div style="display: table-cell; vertical-align: top; width: 340px;">
				<a href="media.php?{vb:raw session.sessionurl}mediaid={vb:raw mediaID}">{vb:raw title}</a><br />
				{vb:raw date} at <span class="time">{vb:raw time}</span> by {vb:raw username}<br /><br />
				<img src="{vb:stylevar imgdir_rating}/rating-trans-15_{vb:raw rating}.png" alt="Rating: {vb:raw rating}" />
			</div>
		</div>
	</div>
	<div style="padding-top: 10px;">{vb:var preview}</div>
	<div style="padding-top: 10px;">Tags:</div>
</li>
http://test.8wayrun.com/media.php
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:25 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03959 seconds
  • Memory Usage 2,250KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (5)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete