• 0

CSS formatting


Question

Hey guys, I've always hated front end design of web sites. I've always loved the back end logic. But I figured it would really help to master it and I have to say I love WPF positioning a heck of a lot more then div positioning. Is there a book out there that provides good examples on how to format divs to get the display you want? The data part is fine but like for example I just want to have one div box float:left and then another div float:right and always hug the right side of the container div. Well the right div just floats to the right as much as the left div takes up space. It never truly "floats" right and hugs the right side of the parent div, which I want it to do. I'm good with back-end logic and C# desktop apps and such. I've just always hated trying to work with divs. It takes WAY too much time then it should. Hopefully that'll improve after reading a book on it.

Link to comment
https://www.neowin.net/forum/topic/1156024-css-formatting/
Share on other sites

13 answers to this question

Recommended Posts

  • 0

Well the front end stuff requires a logical mind too and there are always more than one way to achieve a single thing. I'd say that the best way to learn is to do what I did. Lots of trial and error! Lot's a googling too - you end up at places like stack overflow and w3 schools and more often than know someones usually asked the same question as you have!

Either way, best of luck in your learning :)

Edit: You mention reading a book - I'd personally go through the W3schools tutorials as you can put things into practice as you go along!

  • 0

Ok thanks. Well I know the basics of CSS formatting. I just don't know the tricks to get it to float right and hug the side. That is the main thing at the moment I'm trying to learn (without using gimmicky javascript to achieve it I technically could use jQuery to apply resizing to get what I want but I don't want to cheat). But there are many things like that I could learn that would be useful.

  • 0

css is very powerful but there's a lot of non-optimal ways of doing stuff out there. once you dig through enough google results you'll get a sense of which tutorial/article is higher quality than others.

nothing wrong with googling the end result you want to achive and seeing how different people arrive at that result, that's probably the more effective way of learning the less commonly used CSS properties/selectors/etc

  • 0

<div id="xGSListItmDefDiv" style="margin-bottom:5px;">
        <div id="xHdrDiv">
            <div id="xGSTitleDiv">
                @Html.Raw(gsDef.GarageSaleName)
            </div>
            <div id="xGSDistDiv">
                @Html.Raw(string.Format("{0:0.00sDef.GarageSaleDistance)) mi
            </div>
            <div id="xGSUNameDiv">
                @Html.ActionLink(gsDef.GarageSaleUserName, @UrlHelper.GenerateContentUrl(string.Format("/GetUserProfile/{0}", gsDef.GarageSaleUserId), this.Context))
            </div>
            <div id="xGSTagsDiv">
                Tags (ex. Starwars, Legos, Picklage, Test 1, Test 2, Test 3, Other)
            </div>
            <div id="xGSAddBtnDiv">
                <input id="xAddGSBtn_@Html.Raw(gsDef.GarageSaleId)" type="button" value="Add" />
            </div>
            <div id="xGSRatingDiv">
                * * * * *
            </div>
        </div>
        <div id="xGSBodyDiv">
            <div id="xGSDescDiv">
                Description: @Html.Raw(gsDef.GarageSaleShortDesc)
            </div>
            <div id="xGSAddrOptDiv">
                <div id="xGSAddrDiv">
                    @Html.Raw(string.Format("{0}<br;{1}, {2} {3}", gsDef.GarageSaleStreet, gsDef.GarageSaleCity, gsDef.GarageSaleStateCode, gsDef.GarageSaleZipCode))
                &lt;/div&gt;
                &lt;div id="xGSAddrIfoOptsDiv"&gt;
                    &lt;a href="#" data-id="@Html.Raw(gsDef.GarageSaleId)" data-lat="@gsDef.GarageSaleCoordsLat" data-lng="@gsDef.GarageSaleCoordsLong"&gt;Focus on @Html.Raw(gsDef.GarageSaleName)</a>;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="cDiv"&gt;&lt;/div&gt;
    &lt;/div&gt;

CSS

#xGSListItmDefDiv
{
    width:955px;
    background-color:#CCCCCC;
}

#xGSTitleDiv
{
    min-width:35%;
    max-width:45%;
    float:left;
    margin-right:8px;
}

#xGSDistDiv
{
    float:left;
    margin-right:10px;
    max-width:60px;
    min-width:45px;
}

#xGSUNameDiv
{
    float:left;
    margin-right:8px;
}

#xGSTagsDiv
{
    float:left;
    margin-right:10px;
}

#xGSRatingDiv
{
    float: right;
    max-width:100px;
    margin-right:8px;
}

#xGSAddBtnDiv
{
    float:right;
    max-width:50px;
}

#xGSBodyDiv
{
    display:table-cell;
    width:100%;
}

#xGSDescDiv
{
    float:left;
    width:60%;
}

#xGSAddrOptDiv
{
    float:right;
    width:40%;
}

#xGSAddrDiv
{
    display:inline-block;
    float:right;
    min-width:350px;
    vertical-align:top;
    text-align:left;
}

xGSAddrIfoOptsDiv
{
    display:inline-block;
    float:right;
}

I'm trying to make the address div float to the right and huge the side. However it just sits next to the description div and only extends as far as the left div does :( I've even tried setting percentages for widths because I want the layout to be fluid.

  • 0

Apparently it has to do with the fact I'm setting the xGSBody as table-cell. But I have to do that to get the vertical alignment to top on the text so I don't know what my options are there. I mean it's 2013 we really should have a simple valign:top option at this point and have it float with the way the industry is shifting towards tablets things should naturally expand unless specified otherwise. Not sure what the resolution is though.

  • 0

Something like this?

http://jsfiddle.net/r8tUK/2/

  On 01/06/2013 at 19:38, ACTIONpack said:

You should be using Class and not ID

depends on what's the content, if you submit content you have to use ids in most cases since js, php, asp etc work easier with ids then classes as example js hasn't a document class function but it has a id function (class exists but that works only in modern browsers so not ie8 and lower which makes it troublesome).

  • 0
  On 01/06/2013 at 20:56, fobban said:

Look up css3 flexbox, it makes layouts much easier. Of course it won't work very well with any version of IE (IE10 supports a quite old draft).

One of the easiest way to get good layouts that is cross-browser might be to use an existing framework, e.g. Twitter bootstrap.

yeah flexbox is also a good idea but it would require a jquery/js fallback for IE indeed ^^

So that's why i used inline-box which works even in IE8

  • 0
  On 01/06/2013 at 16:14, sathenzar said:

Hey guys, I've always hated front end design of web sites. I've always loved the back end logic.

If you like logical things, you should try lessCSS - it brings a little bit of logic into CSS, making it quicker to write lots of CSS code.

  • 0
  On 02/06/2013 at 11:14, AndroidOS said:

If you like logical things, you should try lessCSS - it brings a little bit of logic into CSS, making it quicker to write lots of CSS code.

Yeah I love less myself too but it doesn't support calculations like:

width: (total.parent.width - total.previous.child.width);

If that becomes possible in less I'll be the happiest guy on earth :D

But less is indeed very great with support for variables and threading and simple calculations.

This topic is now closed to further replies.
  • Posts

    • I wasn't mad. Sorry if I made it sound like that. Everyone is different. PERIOD.
    • Of course there are distros that are more beginner (an actual word) friendly and have less setup/configuration out of the box. This is really your argument? There is no reason to be mad because someone said they wouldn't recommend your favorite distro to a certain type of user. Are you committed to revenge now even if it takes a lifetime or something? LOL As a community we really need to move past this. New Linux users need to be helped. In the Linux subreddits the advise is even worse. So many come asking what distro to use. Sometimes they don't mention what they use their computer for and there will be 20 comments of not one person asking that and just listing the distro they personally use. That helps no one. One pet peeve of mine is sometimes one will ask what DE they should use for distro and mention they have been using Windows for 30 years. GNOME is not the damn answer! That doesn't mean GNOME is not a good DE. Understand what I am saying?
    • A lot of throwback names listed there 😀
    • Sellful lets you build your own online business using AI — now 76% off by Steven Parker Today's deal from our Apps + Software section of the Neowin Deals store, lets you save 76% off Sellful: ERP Agency Plan lifetime deal. AI-Powered Software and Website Builder for Agencies Ever feel like a client’s needs simply can’t be met on a single platform? With Sellful, it’s all here, and all white labeled. Build anything from simple websites to complex workflows to automate your business in a few clicks. Manage everything from email & social media marketing, to payroll & invoicing. It’s got a white label website builder, online shop, CRM, ERP, marketing, memberships, invoicing, appointments, online courses, project manager, and point of sale functions. Sellful is the only white label platform in the world that is truly all in one, combining all aspects of your business in one place no matter the industry. What can you do with Sellful? Automatically generate amazing websites, funnels, & landing pages in seconds using AI Sell physical & digital products online Keep track of customers with native CRM Automate communication & outreach using AI Manage all aspects of your business in one place Collect emails & phone numbers via forms on your website, then send newsletters to customers with important updates, sales, and discounts Build membership programs with various levels of access for your customers Receive payments from your clients using any number of payment gateways including Paypal, Stripe, Authorize.net, Square & more Have your clients book appointments for services & meetings quickly Build powerful & robust online courses to sell to or instruct people Build communities on Sellful social networking sites with activity feeds, private messaging, & groups See & adjust a visual version of everything going on within your client projects Sync your online shop’s inventory with multiple offline store locations & registers Manage inventory, coupons, & sales through Sellful’s native POS app on your computer Manage employee recruitment, time clocks, payroll & leave requests Automate help desk tasks such as support ticket creation Communicate with your team on multiple chat channels Keep an accounting of your income & expenses Automate billing & website creation for your marketing agency What's in the ERP Agency Plan: White Label Unlimited 10 Sites/Sub Accounts Included 100% White Label For Your Brand Or Your Client's Brand Website Builder Sales Funnel Builder Online Shop Automation Builder CRM & Pipeline Management Email Marketing SMS Marketing Reputation Management 2 Way Communication (Email, SMS & Phone) Appointment Scheduler Memberships Subscriptions Forms, Surveys & Polls Client Portal AI Assistant & Chatbot Social Media Automation Legally Binding Contract Signing Project Management System Online Courses (LMS) Invoicing External CRM Connect Class Attendance & Event Booking Restaurant Builder Support Ticket System Team Chat AliExpress Drop Shipping Accounting Advanced Affiliate Program Community Builder Point Of Sale HR Suite (HR, Time Clock, Payroll & ATS) 5000+ App Integrations 20+ Payment Gateways (No Fees From Us) Custom Mobile App Agency Billing System Setup Wizard Builder Content Cloner Tool Digital Marketing Courses Actionable Marketing PDF Guides Unlimited Contacts Per Site/Sub Account Unlimited Pages Per Site/Sub Account Unlimited Blog Posts Per Site/Sub Account Unlimited Users Per Site/Sub Account Unlimited Products Per Site/Sub Account Unlimited Visitors Per Site/Sub Account 100 Gigs Of File Storage 50,000 Free Email Sends* Unlimited Domain Names Per Site/Sub Account *Email sending can be purchased in packs of 10,000 for $10/Month. You can also add your own external sending service to send without limits. Email sends are shared in a pool throughout all websites and email addresses on the account. System emails are always free. Good to know Length of access: lifetime Redemption deadline: redeem your code within 30 days of purchase Updates included Sellful: ERP Agency Plan (Lifetime) normally costs $1,497 but it can be yours for only $349.97, that's a saving of $1,147.03 (76%) off! For terms, and more details click the link below. Get a lifetime plan to Sellful at 76% off, or learn more Although priced in U.S. dollars, this deal is available for digital purchase worldwide. We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
  • Recent Achievements

    • Collaborator
      NullReference earned a badge
      Collaborator
    • Dedicated
      John Volks earned a badge
      Dedicated
    • One Month Later
      KenKay earned a badge
      One Month Later
    • Week One Done
      KenKay earned a badge
      Week One Done
    • Dedicated
      Amadou earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      660
    2. 2
      ATLien_0
      250
    3. 3
      Xenon
      177
    4. 4
      neufuse
      153
    5. 5
      +FloatingFatMan
      126
  • Tell a friend

    Love Neowin? Tell a friend!