Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. three div side by side

three div side by side

Scheduled Pinned Locked Moved ASP.NET
cssxmlarchitecture
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jojoba2011
    wrote on last edited by
    #1

    This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have googled for two div bellow code : $(function() { var right = $("#center"); $("#toggle").click(function() { $("#left").animate({ "width": "toggle" }, { duration: 250, step: function() { right.css("margin-left", $(this).width()); } }, function() { right.css("margin-left", $("#left").width()); }); }); }); #left { width: 270px; float: left; border: solid 1px red; } #center { margin-left: 270px; border: solid 1px green; } <pre lang="xml"><div id="left"> Test</div> <div id="center"> Test Right</div></pre> now guess that i have three div, i wanna to have same as above. ------------------------------- |left div|center div|right div | ------------------------------- the right and left div are always 170 px (for ex.) and i wanna do that when my left div is empty my center div become bigger (same as below code) and all three div should be side by side .and when my left div is empty the center div become bigger and right div be side of center div. Thanks in advanced !</x-turndown>

    A R 2 Replies Last reply
    0
    • J jojoba2011

      This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have googled for two div bellow code : $(function() { var right = $("#center"); $("#toggle").click(function() { $("#left").animate({ "width": "toggle" }, { duration: 250, step: function() { right.css("margin-left", $(this).width()); } }, function() { right.css("margin-left", $("#left").width()); }); }); }); #left { width: 270px; float: left; border: solid 1px red; } #center { margin-left: 270px; border: solid 1px green; } <pre lang="xml"><div id="left"> Test</div> <div id="center"> Test Right</div></pre> now guess that i have three div, i wanna to have same as above. ------------------------------- |left div|center div|right div | ------------------------------- the right and left div are always 170 px (for ex.) and i wanna do that when my left div is empty my center div become bigger (same as below code) and all three div should be side by side .and when my left div is empty the center div become bigger and right div be side of center div. Thanks in advanced !</x-turndown>

      A Offline
      A Offline
      AContractor
      wrote on last edited by
      #2

      #left { float: left; } #main { float: left; } #right { float:right; } <div id="left"> </div> <div id="main"> <div id="right"> </div> </div> Try that. I think it will do what you described.

      J 1 Reply Last reply
      0
      • A AContractor

        #left { float: left; } #main { float: left; } #right { float:right; } <div id="left"> </div> <div id="main"> <div id="right"> </div> </div> Try that. I think it will do what you described.

        J Offline
        J Offline
        jojoba2011
        wrote on last edited by
        #3

        thanks in advanced but its not working! In other word :

        <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %>

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head runat="server">
        <title>Untitled Page</title>
        <style type="text/css">
        #left
        {
        width: 270px;
        float: left;
        border: solid 1px red;
        }
        #center
        {
        margin-left: 10px;
        width: 740px;
        border: solid 1px green;
        float: left;
        margin-right: 10px;
        }
        #right
        {
        width: 255px;
        float: right;
        border: solid 1px red;
        }
        </style>
        </head>
        <body>
        <form id="form1" runat="server">
        <br />
        <div id="left">
        Test Left</div>
        <div id="center">
        Test center</div>
        <div id="right">
        Test Right</div>
        <br />
        <br />
        </form>
        </body>
        </html>

        this is image when i have three divs : http://i49.tinypic.com/35l85jc.jpg and when the left div is empty i wanna have like : http://i49.tinypic.com/24zfwug.jpg

        D 1 Reply Last reply
        0
        • J jojoba2011

          thanks in advanced but its not working! In other word :

          <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %>

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head runat="server">
          <title>Untitled Page</title>
          <style type="text/css">
          #left
          {
          width: 270px;
          float: left;
          border: solid 1px red;
          }
          #center
          {
          margin-left: 10px;
          width: 740px;
          border: solid 1px green;
          float: left;
          margin-right: 10px;
          }
          #right
          {
          width: 255px;
          float: right;
          border: solid 1px red;
          }
          </style>
          </head>
          <body>
          <form id="form1" runat="server">
          <br />
          <div id="left">
          Test Left</div>
          <div id="center">
          Test center</div>
          <div id="right">
          Test Right</div>
          <br />
          <br />
          </form>
          </body>
          </html>

          this is image when i have three divs : http://i49.tinypic.com/35l85jc.jpg and when the left div is empty i wanna have like : http://i49.tinypic.com/24zfwug.jpg

          D Offline
          D Offline
          dusty_dex
          wrote on last edited by
          #4

          I believe you will need conditional execution to achieve it. msdn.microsoft.com/en-us/magazine/ee335716.aspx

          "It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.

          J 1 Reply Last reply
          0
          • D dusty_dex

            I believe you will need conditional execution to achieve it. msdn.microsoft.com/en-us/magazine/ee335716.aspx

            "It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.

            J Offline
            J Offline
            jojoba2011
            wrote on last edited by
            #5

            thnaks in advanced but i wanna do without Ajax or ... Just with CSS only! Thanks in advanced !

            1 Reply Last reply
            0
            • J jojoba2011

              This doesn't seem like it should be that hard, so if someone could just give me a kick in the right direction, that'd be awesome. I have googled for two div bellow code : $(function() { var right = $("#center"); $("#toggle").click(function() { $("#left").animate({ "width": "toggle" }, { duration: 250, step: function() { right.css("margin-left", $(this).width()); } }, function() { right.css("margin-left", $("#left").width()); }); }); }); #left { width: 270px; float: left; border: solid 1px red; } #center { margin-left: 270px; border: solid 1px green; } <pre lang="xml"><div id="left"> Test</div> <div id="center"> Test Right</div></pre> now guess that i have three div, i wanna to have same as above. ------------------------------- |left div|center div|right div | ------------------------------- the right and left div are always 170 px (for ex.) and i wanna do that when my left div is empty my center div become bigger (same as below code) and all three div should be side by side .and when my left div is empty the center div become bigger and right div be side of center div. Thanks in advanced !</x-turndown>

              R Offline
              R Offline
              Rockstar_
              wrote on last edited by
              #6

              it is best to place in table,

              Then give height, width etc....

              J 1 Reply Last reply
              0
              • R Rockstar_

                it is best to place in table,

                Then give height, width etc....

                J Offline
                J Offline
                jojoba2011
                wrote on last edited by
                #7

                thanks for solution but i wanna to have something like this and increase center div width automatically

                Quote:

                this is image when i have three divs : http://i49.tinypic.com/35l85jc.jpg and when the left div is empty i wanna have like : http://i49.tinypic.com/24zfwug.jpg

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups