New to css. I have a div element, in which there are multiple links in it, now I like to apply css to all of the elements inside the div like below:
#menu {
top: 150px;
left: 650px;
position: absolute;
color: #151B54;
font: 10pt;
font-family: Arial;
}
However this doesn't seem to be working.
Here is the div:
<div id="menu">
<asp:HyperLink ID="lnk_Home" runat="server"
NavigateUrl="~/Default.aspx"> Home </asp:HyperLink>
</span>
<asp:HyperLink ID="HyperLink14" runat="server" NavigateUrl="~/About/About.aspx"
Target="_blank"> About </asp:HyperLink>
<asp:HyperLink ID="HyperLink16" runat="server"
NavigateUrl="~/About/ContactUs.aspx" Target="_blank"> Contact Us </asp:HyperLink>
<asp:HyperLink ID="HyperLink17" runat="server"
NavigateUrl="~/About/FAQ.aspx" Target="_blank"> FAQ </asp:HyperLink>
</div>
None of your CSS styles anything inside of the #menu div.The right way would be like this:
div#menu {
position: absolute;
top: 150px;
left: 650px;
}
/* "<asp>" isn't a valid HTML element, but I assume that
* <asp:Hyperlink> actually generates an HTML anchor */
/* Links also have pseudo-elements that represent their
* valid statuses.*/
div#menu a,
div#menu a:visited,
div#menu a:hover,
div#menu a:active,
div#menu a:focus {
color: #151B54;
font: 10pt;
font-family: Arial;
}
More information about the pseudo-classes mentioned can be found here: http://www.w3.org/TR/CSS21/selector.html#link-pseudo-classes
Not exactly sure what you're asking, as you provided ASP.NET code, but to select elements inside of elements via CSS, you can do it like this:
#menu your_link {
/* Styles */
}
If you could provide the generated HTML, that would be nice.
I think you are looking for something like
#menu asp {
...styles...
}
This will target all <asp> tags inside the #menu element. Your current style only targets the #menu element, not any of its children.
(Although the <asp> tag is non-valid, you could substitute any type of element and the concept still applies.)
Also, there's a rogue <span> element in your code, and a lot of where CSS can do the job. It should maybe look like this:
<div id="menu">
<asp:HyperLink ID="lnk_Home" runat="server" NavigateUrl="~/Default.aspx">
Home</asp:HyperLink>
<asp:HyperLink ID="HyperLink14" runat="server" NavigateUrl="~/About/About.aspx" Target="_blank">
About</asp:HyperLink>
<asp:HyperLink ID="HyperLink16" runat="server" NavigateUrl="~/About/ContactUs.aspx" Target="_blank">
Contact Us</asp:HyperLink>
<asp:HyperLink ID="HyperLink17" runat="server" NavigateUrl="~/About/FAQ.aspx" Target="_blank">
FAQ</asp:HyperLink>
</div>
Related
I have original.css file that i can't remove or change from the page.
original.css
table {
border-collapse: collapse;
border-spacing: 0;
}
The radio buttons are showing a border and only way it seems to go away its when using chromedev tool I remove border-collapse:collapse from the original.css. I been trying to do overwrite it using the code below but nothing works. Any suggestion on how to remove border?
<style>
input[type="radio"] {
margin-left: 10px;
margin-right: 1px;
border: none;
border-spacing: 0;
CellSpacing:-1;
}
</style>
<div class="contact-input-item" style="padding-left: 8.9cm; ">
<label><b>By:</b>
<asp:RadioButtonList ID="send_by" runat="server" RepeatDirection="Horizontal" CssClass="rbl" BorderStyle="None" Style="display: none">
<asp:ListItem Text="Email" Value="Email" /> <asp:ListItem Text="fax" Value="fax" />
</asp:RadioButtonList></label>
More specific CSS will override less specific css. So if you can use the class name as well as the type of item inside of your style tags that might be able to push out that "Table" specification.
<style> .contact-input-item input {...etc...} </style>
Then as a last resort you can use !important:
<style>
.contact-input-item input {
border-collapse:separate !important;
}
</style>
I have got a problem with use css file, in tag "nav".
I don't want to have list in nav so I remove that. In the page working on example "line-height", but doesn't work on example "color", "text-decoration". How can I improve that?
nav {
text-decoration: none;
width: 7%;
color:orange;
overflow: hidden;
float: left;
margin-top:20px;
line-height:55px;
}
This is code in html5:
<nav >
<a href="1.html">1 <br />
<a href="1.html">2 <br />
<a href="1.html">3 <br />
<a href="1.html">4 <br />
<a href="1.html">4 <br />
<a href="1.html">j4 <br />
</nav>
If I understood your problem correctly, you are having problem with styling the a tag inside the nav tag.
Try using the following CSS selector:
nav {
width: 7%;
overflow: hidden;
float: left;
margin-top:20px;
line-height:55px;
}
nav a{
text-decoration: none;
color:orange;
}
It's an asp project with javascript and css. I have taken the java from this site JonDesign's SmoothGallery demo.
Now I want to put the tag p which has the summary inside, out of the div,
by the way here is the code:
<div id="myGallery">
<asp:Repeater ID="HeadLinesRepeater" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<div class="imageElement">
<h3><%# Eval("Title") %></h3>
<div>
<p><%# Eval("Summary") %></p>
</div>
<img class="full" src='<%# "/Img/news/" + Eval("ID") + ".jpg" %>' />
<img class="thumbnail" src='<%# "/Img/news/" + Eval("ID") + ".jpg" %>' style="width: 100px; height: 75px" />
</div>
</ItemTemplate>
</asp:Repeater>
</div>
CSS:
.jdGallery .slideInfoZone p {
float: right;
margin-bottom: 10px;
z-index: 1000000;
position: absolute;
margin-left: 92px;
width: 300px;
right: 670px;
top: 220px;
font-family: Tahoma;
font-size: 10pt !important;
text-align: justify;
color: white !important;
padding: 0;
font-size: 60%;
margin: 2px 5px;
color: #eee;
}
If I change position to the fixed it will be solved but ahen the I open the site in other resolution it would be unscrambled and goes to inside other divs.
It's my project for university please help me.
Just phisycally cut the <p><%# Eval("Summary") %></p> and paste it outside the div.
EDIT
What about styling the inner p with display:none, then create your own javascript (Do you have JQuery referenced in this page?) to grab all the paragraphs and append them elsewhere in the DOM.
But really it seams (from your comment) you need to change the javascript that manipulates the parent div to not depend on the inner paragraph, or change it to work with the paragraph in a different position in the DOM.
I have an ASP.Net Hyperlink with a set height. The text is rendered at the top left of it. How do I vertically center it (-the text)?
(In C# I'd have: label1.TextAlign = ContentAlignment.MiddleCenter; . How is it done in ASP.Net?)
Tried the following but it doesn't work (neither on FF nor on IE).
<form id="form1" runat="server">
<div>
<asp:HyperLink NavigateUrl="~/WebForm1.aspx" runat="server" CssClass="MyClass" BackColor="White"
Height="100px" Text="MyText" Width="200px" ></asp:HyperLink>
</div>
</form>
And:
.MyClass
{
display: table-cell;
text-align: center;
vertical-align: middle;
}
Add the following styles to your HyperLink:
display:table-cell;
text-align:center;
vertical-align:middle;
If you are going to reuse that style is better to define a class:
<asp:HyperLink ... class="myClass" >HyperLink</asp:HyperLink>
and then in your stylesheet:
.myClass{
display:table-cell;
text-align:center;
vertical-align:middle;
}
Or add the styles inline:
<asp:HyperLink ... style="display:table-cell;text-align:center;vertical-align:middle;" >HyperLink</asp:HyperLink>
Add folowing attributes to the CssClass or the inline style:
{
display: table-cell;
vertical-align: middle;
line-height: 32px;
}
note that replace "32px" with your height of Hyperlink.
I have two div's one has textbox in it and other just plain text. This is how it looks:
. I want to move text div which has language in it to the next line where arrow is showing in the pic. I searched every where cant find any solution the wordwrap is not working. Also i have to do this within css.
Here is the aspx code for both:
<asp:Panel ID="search" runat="server" EnableViewState="False" Wrap="False">
<div id="txtBox">
<asp:textbox id="box" runat="server"></asp:textbox>
<div id="text" runat="server">Language</div>
</div>
</asp:Panel>
css:
#search
{
position:absolute;
top:100px;
height:50px;
left:100px;
width:1000px;
}
#txtBox
{
float: left;
}
Here is the solution for anyone who is stuck in same situation:
#text
{
clear: left;
}
clear:left moves the text to next line to the bottom of the textbox. Then you can use margin-left to set the text at any position you want.
You don't want to use float:left in this situation. float:left is for stacking block level HTML elements horizontally.
block level elements automatically stack vertically, which seems to be what you want.
However, the <asp:TextBox> is an inline level element, so you can put a <br /> after it, or wrap it in a <div>.
Solution:
HTML
<asp:Panel ID="search" class="search-class" runat="server" EnableViewState="False" Wrap="False">
<div id="txtBox">
<asp:textbox id="box" runat="server"></asp:textbox>
<br />
<div id="text" runat="server">Language</div>
</div>
</asp:Panel>
OR
<asp:Panel ID="search" class="search-class" runat="server" EnableViewState="False" Wrap="False">
<div id="txtBox">
<div>
<asp:textbox id="box" runat="server"></asp:textbox>
</div>
<div id="text" runat="server">Language</div>
</div>
</asp:Panel>
CSS
.search-class
{ /* Curt is right, the ID="search" is in a naming container, */
/* so use class selector */
position:absolute;
top:100px;
height:50px;
left:100px;
width:1000px;
}
have you tryed doing:
clear:both on the div with the language?
and maybe you should contain the textbox
/* Containing floats */
.contain:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
/* IE6 */
* html .contain {
height: 1%;
}
/* IE7 */
*:first-child+html .contain {
min-height: 1px;
}
When ASP.NET controls are rendered to the client, they sometimes produce different IDs (unless specified otherwise in ASP.NET 4).
Looking at your code, I don't see any control with an ID of txtBox, so these styles aren't being applied.
When working with ASP.NET, I find its best to use classes for styling, as these will stay the same after rendering.
<asp:Panel ID="search" runat="server" EnableViewState="False" Wrap="False" CssClass="search">
<div id="txtBox">
<asp:textbox id="box" runat="server" CssClass="txtBox"></asp:textbox>
<div id="text" runat="server">Language</div>
</div>
</asp:Panel>
.search
{
position:absolute;
top:100px;
height:50px;
left:100px;
width:1000px;
}
.txtBox
{
float: left;
}
I haven't tested this code, but you should now see these styles applying correctly, and therefore you can amend them as you wish.