• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Alpha_ProgDes

Why won't CSS background-color show?

5 posts in this topic

This is my CSS

 

 

body {
    background-color:#e7e7e7;
}

#whynobkgrcolor
{
    background-color:white;
}
 

 

 

This is my HTML

 

<body>
    <form id="form1" runat="server">
       <div id="whynobkgrcolor">
           <div style="float:left">
             <table>
               <tr><td>Column></td></tr>
               <tr><td>Hi!</td></tr>
             </table>
           </div>
       </div>
    </form>
</body>

The div (whynobkgrcolor) has the same background color as the body. Which is gray. As opposed to white. Why? And how do I fix it?

0

Share this post


Link to post
Share on other sites

Several browsers contain developer tools for debugging this kind of stuff. For example, in Chrome, you can right click on an element, say "Inspect Element," and then (once you've ensured you're focusing on the right element), expand the "Computed Style" section on the right. It'll show the computed background color, and if you expand it, it will show you which rules were used to compute the result (and it'll show striked-out text for rules that were overridden by other rules).

 

Sorry I can't say for sure what your problem is, but I'd seriously suggest using browser tools to debug this.

 

Edit (after ApochPiQ posted): He's got a point about floating elements. They can have issues because parent elements may not contain them like you'd expect. In order to make them contained like you expect, you have to implement a "clearfix" hack, a popular example of which is on this StackOverflow question. One common way this is done is by making a CSS class rule .clearfix { /* ...typically stuff like what's in the Stack Overflow question... */ } and then just specifying elements with class="clearfix" as necessary. You can also use Chrome's (or any other decent browser's) tools to show how the dimensions are calculated for an element, which might be useful too.

Edited by Cornstalks
2

Share this post


Link to post
Share on other sites

ApochPiq's second solution did the trick.

 

Thanks guys!

 

For the record, I'm coding for IE9 and IE10 browsers.

Edited by Alpha_ProgDes
0

Share this post


Link to post
Share on other sites
A floated element is taken out of the natural flow of the page and so doesn't contribute to the sizing of the parent-div which has no other content so it collapses to a size of zero, hence no background.

As ApochPiQ hints at with his first solution, your markup as posted has no use for the outer-div, so just apply the background to the inner one.

Otherwise you need a way to force the outer-div to contain the inner one. One way is the "clearfix hack" which has already been demonstrated. Another way is to simply tell it what to do when content overflows its boundaries. The default overflow behaviour is "visible", which just permits content to overflow but we can change to "auto" which will tell it to expand and contain all content (or if expanding isn't possible then display a scroll bar):


#whynobkgrcolor
{
    background-color:white;
    overflow: auto;
}
0

Share this post


Link to post
Share on other sites

ApochPiq's second solution did the trick.

 

Thanks guys!

 

For the record, I'm coding for IE9 and IE10 browsers.

 

Even If you are coding "For" IE9 or IE10 , use chrome for development, the better developer tools are worth it and IE9/10 have good enough support for standard HTML and CSS to not need that much special care unless you are playing around with some of the less popular HTML5 features.

 

If you are trying to get things to work properly in IE7 or 8 your best bet is to run the javascript version of firebug for internet explorer (which provides a not completely useless set of developer tools for IE)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0