Solved

problem with CSS

Posted on 2011-03-24
5
216 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
crm development 2 36
Responsive CSS question 2 39
Problem to page 4 17
Achieve json result 2 28
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.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

708 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

18 Experts available now in Live!

Get 1:1 Help Now