?
Solved

problem with CSS

Posted on 2011-03-24
5
Medium Priority
?
222 Views
Last Modified: 2012-05-11
Hello guys,

I am not a web developer and trying to do something fancy with my web form design. I am trying to place two if the divs side by side and I am not able to. Can anybody pls tell me what I am a doing wrong?

This is small pice of my small code:

<form id="form1" runat="server">
    <div>
    <div id = "Switch" style= "background-color:blue; height:300px; left:0px; top:0px; width:20px"></div>
    <div id = "chart" style = "background-color:Olive;left:0px; top: 0px;height:300px"></div>
    </div>
    <br  />
    <div id = "container" style = " position:relative; left:100px; top:0px;" >         
    <asp:GridView ID="GvRegistration" runat="server" AutoGenerateColumns="False"
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
            CellPadding="4" ForeColor="Black" GridLines="Horizontal" Height="454px"
            Width="406px" AllowPaging="True" AllowSorting="True"    
        onsorting="GvRegistration_Sorting">
        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F7F7F7" />
        <SortedAscendingHeaderStyle BackColor="#4B4B4B" />
        <SortedDescendingCellStyle BackColor="#E5E5E5" />
        <SortedDescendingHeaderStyle BackColor="#242121" />
    </asp:GridView>
    </div>
   
Positioning-issue.png
0
Comment
Question by:TheCommunicator
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 9

Accepted Solution

by:
xav056 earned 500 total points
ID: 35212129
float your divs as below
  <div>
    <div id = "Switch" style= "background-color:blue; height:300px; left:0px; top:0px;

width:20px; float:left;"></div>
    <div id = "chart" style = "background-color:Olive; top:

0px;height:300px;float:left;width:300px;"></div>
    </div>
0
 
LVL 13

Assisted Solution

by:gamarrojgq
gamarrojgq earned 500 total points
ID: 35212131
Hi,

There are a couple of ways to solved, but an easy one is use a table

    <table>
        <tr>
            <td>
                <div id = "Switch" style= "background-color:blue; height:300px; left:0px; top:0px; width:20px"></div>
            </td>
            <td>
                <div id = "chart" style = "background-color:Olive;left:0px; top: 0px;height:300px"></div>                              
            </td>
        </tr>
    </table>  

Hope that helps
0
 
LVL 10

Assisted Solution

by:10023
10023 earned 1000 total points
ID: 35212390
<HTML>
<HEAD>

<TITLE></TITLE>


<STYLE TYPE="text/css">
#container {
}
#switch {
      float: left;
      width: 700px;
height:100px;
      margin: 0;
      padding: 0;
}

#chart {
      float: left;
      width: 700px;
      height:100px;
      margin: 0;
      padding: 0;
}

</STYLE>
</HEAD>

<BODY >

<form id="form1" runat="server">
    <div id= "container">
    <div id = "Switch" style= "background-color:blue;"></div>
    <div id = "chart" style = "background-color:Olive;"></div>
   
 
    <div id = "bottom" style = "background-color:black;  float: left; top: 210px; left: 0px; width: 700px; height: 100px;" >         
   
</div>
    </div>
</BODY>
</HTML>
0
 

Author Comment

by:TheCommunicator
ID: 35217980
Hi guys,

I converted it into float: left and it seesm to work fine. Thank you.

Then it made me curious and I though to try the tables and then it did nto produce good results. My code is as following:

<table style= "background-color:Gray;">
    <tr>
    <td id = "Switch" style= "background-color:blue; height:100px; top:0px; width:10%;"></td>
    <td id = "chart" style = "background-color:Olive; top:0px; height:100px; width:90%;"></td>
    </tr>
   
    <tr id = "container" style = " position:relative; left:100px; top:0px;">              
    <asp:GridView ID="GvRegistration" runat="server" AutoGenerateColumns="False"
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
            CellPadding="4" ForeColor="Black" GridLines="Horizontal" Height="454px"
            Width="406px" AllowPaging="True" AllowSorting="True"    
        onsorting="GvRegistration_Sorting">
        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F7F7F7" />
        <SortedAscendingHeaderStyle BackColor="#4B4B4B" />
        <SortedDescendingCellStyle BackColor="#E5E5E5" />
        <SortedDescendingHeaderStyle BackColor="#242121" />
    </asp:GridView>
    </tr>
    </table>

and I am attaching the screenshot of the results. i am not sure what exactly is worng.
Bad-CSS.png
0
 
LVL 10

Assisted Solution

by:10023
10023 earned 1000 total points
ID: 35218264
I noticed you left your table data <td> container</td> out in your last <tr> table row</tr>
I don't have your ASP form so i filled
I think most designers accept divs as a solution over tables...google tables versus divs

<HTML>
<HEAD>

<TITLE></TITLE>


<STYLE TYPE="text/css">
<!--
... Type style here!
-->
</STYLE>
</HEAD>

<BODY>

<table style= "background-color:Gray;">
    <tr>
    <td id = "Switch" style= "background-color:blue; height:100px; top:0px; width:10%;"><p> This is the first cell</p></td>
    <td id = "chart" style = "background-color:Olive; top:0px; height:100px; width:90%;"><p> This is the second cell</p></td>
    </tr>
   
    <tr id = "container" style = " position:relative; left:100px; top:0px; width: 100%">
<td> <p>And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell,And Now we have the lonely bottom data cell, cell            
    <asp:GridView ID="GvRegistration" runat="server" AutoGenerateColumns="False"
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
            CellPadding="4" ForeColor="Black" GridLines="Horizontal" Height="454px"
            Width="406px" AllowPaging="True" AllowSorting="True"    
        onsorting="GvRegistration_Sorting">
        <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F7F7F7" />
        <SortedAscendingHeaderStyle BackColor="#4B4B4B" />
        <SortedDescendingCellStyle BackColor="#E5E5E5" />
        <SortedDescendingHeaderStyle BackColor="#242121" />
    </asp:GridView>
</td>
    </tr>
    </table>
</BODY>
</HTML>
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question