This article will show you how you can use style sheet to make a div box align to left side of each other. In this article i have used css style sheet to align the div at the left of each other. So for this we add some div controls in the page.
- <div>Div Control 1</div>
- <div>Div Control 2</div>
- <div>Div Control 3</div>
- <div>Div Control 4</div>
- <br style="clear: left;" />
- <div>Div Control 5</div>
- <div>Div Control 6</div>
- <div>Div Control 7</div>
- <div>Div Control 8</div>
- .floatleft_div
- {
- float: left;
- width: 100px;
- height: 100px;
- background-color: green;
- text-align: center;
- border: 2px solid black;
- }
The above css style sheet used float left for making div control move to left of each other. In this width and height is used for make the div control look like a box.
Now assign the style to the div control.
- <div class="floatleft_div">Div Control 1</div>
- <div class="floatleft_div">Div Control 2</div>
- <div class="floatleft_div">Div Control 3</div>
- <div class="floatleft_div">Div Control 4</div>
- <br style="clear: left;" />
- <div class="floatleft_div">Div Control 5</div>
- <div class="floatleft_div">Div Control 6</div>
- <div class="floatleft_div">Div Control 7</div>
- <div class="floatleft_div">Div Control 8</div>
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication7.Csharpcorner.WebForm1" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>Flot Div Control Side By Side Using Css or Style Sheet in Asp.net</title>
- <style>
- .floatleft_div
- {
- float: left;
- width: 100px;
- height: 100px;
- background-color: green;
- text-align: center;
- border: 2px solid black;
- }
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div class="floatleft_div">Div Control 1</div>
- <div class="floatleft_div">Div Control 2</div>
- <div class="floatleft_div">Div Control 3</div>
- <div class="floatleft_div">Div Control 4</div>
- <br style="clear: left;" />
- <div class="floatleft_div">Div Control 5</div>
- <div class="floatleft_div">Div Control 6</div>
- <div class="floatleft_div">Div Control 7</div>
- <div class="floatleft_div">Div Control 8</div>
- </form>
- </body>
- </html>


Join the conversation! Your thoughts help the community grow.