How can vertical align bottom and top at the same time? - html

I want to vertical align some elements at the top of the td element and some other elements to be at the bottom of td element .
this is my code :
<ItemTemplate>
<td runat="server" style="position:relative;vertical-align:top;">
<a runat="server" href='#' class="Up">
</a>
<br />
<asp:Label ID="ProductNameLabel" CssClass="Up"/>
<br />
<asp:Label ID="SummaryLabel" CssClass="Up"/>
<br />
<asp:Label ID="PriceLabel" CssClass="Down" />
<br />
<a runat="server" href="#" class="Down">
</a>
<br />
<asp:Button ID="Button1" CssClass="Down" />
</td>
</ItemTemplate>
The elements from the "Up" class i want to be displayed at the top of the td and the elements in the "Down" class at the bottom of the td .
i tried this css :
.Up {
top:0px;
}
.Down {
bottom:0px;
}
And it didn't work . Can someone help me find the solution ?

It would help if you only provided HTML and CSS in your example.
In any case, I think what you are looking for is position:absolute
.Up {
position:absolute;
top:0;
}
.Down {
position:absolute;
bottom:0;
}
This will position them relative to the first parent that has a position:relative on it.
Note, I also removed the px from your 0 as it's not necessary to specify that when the value is 0. 0em = 0px = 0% = 0
Here is a more complete example.

Related

When I resize window menu doesn't remain fixed

I am not able to keep my menu fix whenever I resize my window my menu doesn't remain fix and it keep moving down towards left. I want all my text, pictures and menus to remain fix but can be moved to certain extent and after that it should be scrollable like other websites.
I am sharing screenshot with what happen when I scroll the webpage:
This is how when it is maximised which is fine
This is when it is minimised all the text, menu buttons moves but doesn't stay where they are.
I am sharing you the script for this:
.auto-style19 {
color: Highlight;
font-size: 18pt;
position: relative;
width:672px;
display: inline-block;
float: right;
margin-right: 10% auto;
font-family: 'Times New Roman', Times, serif;
top: 49px;
min-height: 196px;
margin-top: 0px;
left: -21px;
height:auto;
}
.auto-style26 {
position:relative;
min-width: 80%;
width:auto;
top: 0px;
left: 0px;
min-height: 505px;
overflow:hidden;
height:auto;
display:block;
}
.auto-style34 {
position: absolute;
left: 64px;
float: left;
width: 500px;
top: 14px;
}
.auto-style36 {
width: 677px;
}
<div style="margin-top:40px;margin:auto;" class="auto-style26">
<div style="display:inline-block;margin-top:50px;margin-right:20px;" class="auto-style34" >
<asp:Image ID="Image1" runat="server" height="300px" width="200px" CssClass="img1"/>
<asp:Image ID="Image2" runat="server" height="300px" width="200px" />
</div>
<div class="auto-style19" >
<table class="auto-style36">
<tr><td class="auto-style28"> <asp:Label ID="Label2" runat="server" ForeColor="Highlight" style="text-transform:capitalize;" Font-Size="14pt" Text="Address: " Font-Bold="True"></asp:Label></td>
<td class="auto-style29"> <asp:Label ID="LabelAddress" runat="server" ForeColor="White" style="text-transform:capitalize;" Font-Size="13pt" ></asp:Label></td>
<td rowspan:3 class="auto-style27"><ul id="edit"><li> <a id="edit1" href="#" runat="server" >Edit Info</a>
<ul>
<li><asp:HyperLink ID="HyperLink1" runat="server" Font-Size="16pt" Font-Underline="false" NavigateUrl="~/EditPic1.aspx">Edit Profile Pic 1</asp:HyperLink></li>
<li><asp:HyperLink ID="HyperLink2" runat="server" Font-Size="16pt" Font-Underline="false" NavigateUrl="~/EditPic2.aspx">Edit Profile Pic 2</asp:HyperLink></li>
<li><asp:HyperLink ID="HyperLink3" runat="server" Font-Size="16pt" Font-Underline="false" NavigateUrl="~/EditAddress.aspx">Edit Address and Phone</asp:HyperLink></li>
<li> <asp:HyperLink ID="HyperLink4" runat="server" Font-Size="16pt" Font-Underline="false" NavigateUrl="~/Change Password.aspx">Change Password</asp:HyperLink></li>
<li> <asp:HyperLink ID="HyperLink5" runat="server" Font-Size="16pt" Font-Underline="false" NavigateUrl="~/Change Payment Method.aspx">Change Payment Method</asp:HyperLink></li>
</ul>
</li>
</ul></td>
</tr>
<tr>
<td class="auto-style30"><asp:Label ID="Label5" runat="server" ForeColor="Highlight" style="text-transform:capitalize;" Font-Size="14pt" Text="Age: " Font-Bold="True"></asp:Label></td>
If you want the images and the menus on the right to scale with window size, don't specify a specific width for them. You could set a min-width to ensure that they do not go below a specific width, but other than that, give the two containers a percentage width of its parent container to have them scale in size as you resize the window.

How do I move this icon/button? CSS?

I'm just learning asp.net, VB, SQL and CSS. I am writing a dating site and want the "likes" icon to sit next to the other 3 centralised icons just above it. The first 3 icons are simply images at the moment but the Likes icon is in DIVS and does function correctly but ends up on the row below even though there's plenty of space to fit it next to them. Many thanks for any help...
<asp:Image ID="Imagelove" runat="server" width="90px" ImageUrl="~/files/images/loveicon.png" />
<asp:Image ID="ImageGift" width="90px" runat="server" ImageUrl="~/files/images/gift.png" />
<asp:Image ID="ImageReport" width="90px" runat="server" ImageUrl="~/files/images/report.png" />
<div style="width:90px; height:89px; position:relative; background: url('/files/images/likebutton.png'); cursor: pointer;" onClick="addLike('<%# Eval("orderID")%>')">
<div style="font-size:12px; color:#000; background:#ffffff; border:1px solid #000; padding:0 3px; float:left; margin: 0px 0 0 55px;" id="<%# Eval("orderID")%>"><%# Eval("likeCounter")%>
</div>
</div>
I have found the solution myself thank you. I added display: inline-block; in to the DIV Style="" part.

Why can't I use CSS to move button?

This is my code and I'm unable to style it using 'button {margin-top:10px}
<input type="text"></input><button type="button"><img src="searchlogo.png" id="search"></button>
It isn't aligning flush with the text input? Any tips?
To see how does margin working please see this demo
CSS
.b1{
background:orange;
color:white;
border:none;
}
.b2{
background:orange;
color:white;
border:none;
margin-top:100px;
}
HTML
<input type="text"></input><button class="b1">Button Title</button>
<br/>
<input type="text"></input><button class="b2">Button Title</button>
<br/>
<input type="text"></input><button class="b1">Button Title</button>
I suspect you have an overriding rule somewhere in your css somewhere that prevents your css code from doing what you intend to do.
You should specify the element that you want to implement the margin on instead of broadly calling on button for the margin-top: 10px; rule.
Try this:
On your HTML:
<button class="my-button"><img src="image.jpg" alt="image" /></button>
On your CSS:
button.my-button {
margin-top: 10px;
}
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" CssClass="button" />
<head runat="server">
<title></title>
<style type="text/css">
.button
{
margin-top: 20px;
}
</style>

Removing bullets from asp.net menu

I can't seem to get rid of bullets in my menu. Can anyone help me?
Master page code:
<asp:Menu ClientIDMode="Static" ID="main_menu" runat="server" Orientation="Horizontal">
<StaticItemTemplate>
<div class="nav_style">
<asp:Label runat="server" Text='<%# Eval("Text") %>' />
</div>
</StaticItemTemplate>
<Items>
<asp:MenuItem NavigateUrl="~/home.aspx" Text="home" />
<asp:MenuItem NavigateUrl="~/what-it-can-do.aspx" Text="what it can do" />
<asp:MenuItem NavigateUrl="#" Text="pricing" />
<asp:MenuItem NavigateUrl="#" Text="news & events" />
<asp:MenuItem NavigateUrl="#" Text="partner with us" />
</Items>
</asp:Menu>
Here is my CSS code:
.nav_style
{
list-style-type:none;
background-color:#242C32;
border-radius:3px;
color:#F5F5F5;
border-top:6px solid #242C32;
border-bottom:6px solid #242C32;
border-left:12px solid #242C32;
border-right:12px solid #242C32;
font:13px calibri;
}
Here is the generated HTML:
<div id="main_menu">
<ul class="level1">
<li><a class="level1 selected" href="home.aspx">
<div class="nav_style">
<span>home</span>
</div>
</a></li><li><a class="level1" href="what-it-can-do.aspx">
<div class="nav_style">
<span>what it can do</span>
</div>
</a></li><li><a class="level1" href="#">
<div class="nav_style">
<span>pricing</span>
</div>
</a></li><li><a class="level1" href="#">
<div class="nav_style">
<span>news & events</span>
</div>
</a></li><li><a class="level1" href="#">
<div class="nav_style">
<span>partner with us</span>
</div>
</a></li>
</ul>
</div>
EDIT
Not any of the answers seems to be working for me, any other suggestions? Thank you.
Managed to do it myself. In my css file there was a background set for bullets for the whole page
background:url('../img/blue_bullet.png')
so I added to my css
.nav_style li
{
background:none;
}
Redefine the css style as:
.nav_style ul
{
...
}
Remove nav_style class from the div. Instead use CssClass = "nav_style" in the Menu markup.
FYI, just came on this and nothing mentioned worked. Examining the rendered html shows that a table cell was being appended to my list item (the whole menu is a table rendered structure) and using a bullet icon as a background image from webkit. To override that, specify your own bullet, which in my case, was nothing. So I made a 2x2px white png file and specified the "static pop up image url" (StaticPopoutImageURL) control property which is used as the bullet cell's background. The following is in the menu control layout code:
<asp:Menu ID="MyMenu" runat="server"
DisappearAfter="100"
StaticDisplayLevels="1"
Orientation="Vertical"
StaticPopoutImageURL="/Images/White2x2px.png"
CssClass="my anchor/ul styles">
.....
</asp:Menu>
Hopes this helps someone since I couldn't find the answer anywhere.
Jim
Try this:
#main_menu ul
{
list-style:none;
}
Try this to reset it with css:
#main_menu *
{
list-style: none;
}
Demo
For your generated HTML, the following block should get you rid of the bullets.
.level1
{
list-style:none;
}
A more generic way is to target the generated <ul> with something like the following:
#main_menu ul
{
list-style:none;
}
A working example: http://jsfiddle.net/U2Vgf/1/

Programmatically removing CSS class files - jQuery

I am using the jQueryUI library to take advantage of tabs on my page and the CSS styles of the tabs are being applied to the content within the div tags.
When I use the Chrome Developer tools I have narrowed it down to the following CSS classes in in the jquery-ui.css class:
.ui-widget {
/*font-family: Verdana,Arial,sans-serif;*/
font-size: 1.1em/*{fsDefault}*/;
}
.ui-widget .ui-widget {
font-size: 1em;
}
How do I remove these CSS styles from my div content containers. I tried the following jQuery snippet and it did not work.
$("#nameSearch").removeClass("ui-widget");
Here is a snippet of my HTML page:
<div id="searchTabs">
<ul>
<li>Name</li>
<li>Case Number</li>
</ul>
<div id="nameSearch">
<b>First Name:</b> <asp:TextBox ID="txtFirstNameSearch" runat="server" CssClass="txt" /><br />
<b>Last Name:</b> <asp:TextBox ID="txtLastNameSearch" runat="server" CssClass="txt" /><br />
<b>Date of Birth:</b> <asp:TextBox ID="txtDateOfBirth" runat="server" CssClass="txt" /><br />
</div>
<div id="caseNumberSearch">
<b>Case Number:</b> <asp:TextBox ID="txtCaseNumberSearch" runat="server" CssClass="txt" /><br />
</div>
</div>
If you know the position of those CSS rules, then:
IE
document.styleSheets[0].removeRule(i);
//i = position of the rule.
Other Browsers
document.styleSheets[0].deleteRule(i);