皮肤和样式表菜鸟问题
我有一个外观文件,其中包含:
< asp:TextBox runat="server" CssClass="FixedFont"/>
在与外观文件相同的文件夹中,是以下 css 文件。 Css 文件包含:
.FixedFont
{
font-family:Courier;
}
最后,我有一个包含以下控件的 ASPX 页面:
<asp:TextBox ID="TextBox1" runat="server">Test</asp:TextBox>
当我在设计模式下查看 ASPX 页面或运行该页面时,我看到样式上的 font-family 属性确实影响文本框控件,即,改为快递。
然而,我还想做的是在我的 ASPX 页面上定义本地样式,
.DefaultWidth
{
width: 300px;
}
...并让我的所有文本框具有相同的宽度。
如果我将 TextBox1 的 CssClass 属性设置为“DefaultWidth”...
<asp:textbox ID="TextBox1" CssClass="DefaultWidth">Hello</asp:TextBox>
...文本框的宽度更改为 300px,但我失去了应用修复字体 Courier 样式的皮肤效果。
为了应用这两种效果,即 DefaultWidth 和固定字体文本框效果,我必须将 CSSClass 属性设置为“DefaultWidth FixFont”,对我来说,这似乎首先破坏了拥有皮肤的优势。我想我预计效果是累积的,除非我添加了与皮肤冲突的样式,在这种情况下,我预计本地类将应用于皮肤的效果。例如,如果我应用了第二个类 Class2,除了其他效果之外,它还包含字体系列规范,我希望 Class2 中指定的字体会覆盖固定字体样式中的字体。但这似乎并不是这里发生的事情。
处理这种情况的最佳方法是什么?我经常想拥有一系列宽度都匹配的文本框,因此我想除了使用应用于外观文件中类型的控件的效果之外,我还经常想在控件上指定 CssClass。
解决方案是不在 SKIN 本身中使用 CSS 吗?这在维护方面似乎也有缺点。
我遇到的第二个问题是,如果我声明具有以下类的样式表...
.Button
{
background-image: url('/images/button.gif')
}
并将 ASP 按钮的 CSSClass 属性设置为“按钮”,我会看到图像平铺在按钮上。
但是,如果我在皮肤文件中输入以下代码,
它不会找到图像。
图片文件夹是网站根目录下的一级文件夹。
知道为什么它没有拾取图像。我尝试过各种其他途径,但这似乎是唯一对我有意义的途径。
顺便说一句,该图像是在设计模式下应用的,但是当运行 ity 时它就消失了。
I have a Skin File that contains:
< asp:TextBox runat="server" CssClass="FixedFont"/>
In the same folder as the Skin file, is the following css file. The Css file contains:
.FixedFont
{
font-family:Courier;
}
Lastly, I have an ASPX page which contains the following control:
<asp:TextBox ID="TextBox1" runat="server">Test</asp:TextBox>
When I view the ASPX page in design mode or run the page, I see that the font-family attribute on the style does effect the textbox control, namely, it is changed to Courier.
However, what I would also like to do is to define a local style on my ASPX page,
.DefaultWidth
{
width: 300px;
}
...and have all of my TextBoxes so that they are the same width.
If I set the CssClass property of TextBox1 to "DefaultWidth"...
<asp:textbox ID="TextBox1" CssClass="DefaultWidth">Hello</asp:TextBox>
...the width of the textbox is changed to 300px but I lose the effect of the skin appling the fix font Courier style.
To get BOTH effects to be applied, the DefaultWidth and the fixed font textbox effect, I have to set the CSSClass property to "DefaultWidth FixedFont", which to me, seems like it defeats the advantage of having the skin in the first place. I guess I expected the effect to be CUMULATIVE, unless I added a style that conflicted with the SKIN, in which case, I expected the local class to be applied over the skin's effect. For example, If I applied a second class, Class2, that also included a font-family specification in addition to other effects, I would expect the font specified in Class2 to override that in the FixedFont style. But that doesn't appear to be what is going on here.
What is the best way to manage such a situation? I imagine very often wanting to have a series of textboxes that all match in width, so I imagine that I will very often want to specify a CssClass on a control in addition to using the effects applied to the control in type in the skin file.
Is the solution NOT to use CSS in the SKIN itself? This seem like it has disadvantages, too, on the side of maintenance.
A secondary problem that I am having is that if I declare a stylesheet with the following class..
.Button
{
background-image: url('/images/button.gif')
}
...and set the CSSClass property of an ASP Button to "Button", I see the image tiled over the button.
However, if I enter the following code in the skin file
it does not find the image.
The images folder is a first-levl folder off of the root of the website.
Any idea why it is not picking up the image. I;'ve tried various other paths, but that is the only one that seems to make sense to me.
By the way, the image is applied in design mode, but it disappears when ity is run.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道我是否理解你的问题,但正如我从这里看到的,你应该以你的“本地”风格声明这一点:
或者如果你确定影响每个具有相同宽度的文本框,则简单地声明到每个文本框,皮肤无关紧要...
如果这不是您所要求的,请说得更清楚。
I don't know if I understood your question but as I'm seeing from here, what you should have to declare this in your "local" style:
or simply to every textbox if you are sure about affecting every textbox with the same width, doesn't matter the skin...
If this not what you were asking for, please be clearer.