Solved

problem with CSS

Posted on 2011-03-24
5
217 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
5 Comments
 
LVL 9

Accepted Solution

by:
xav056 earned 125 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 125 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 250 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Button Css BootStrap 2 33
Data is not showing from images 15 37
Error in JQuery 5 36
IIS issues - Convert to Application - APS.NET v4.0 3 21
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now