这是情况......在顶层,我有一个TabControl.TabControl中的每个页面都包含一个ListBox:
<TabControl>
<TabItem Header="item 1">
<ListBox>
<ListBoxItem>sub item 1</ListBoxItem>
<ListBoxItem>sub item 2</ListBoxItem>
<ListBoxItem>sub item 3</ListBoxItem>
</ListBox>
</TabItem>
<TabItem Header="item 2">
<ListBox>
<ListBoxItem>sub item 1</ListBoxItem>
<ListBoxItem>sub item 2</ListBoxItem>
</ListBox>
</TabItem>
</TabControl>
Run Code Online (Sandbox Code Playgroud)
ListBoxes有一个水平方向的StackPanel作为它们的ListTemplate:
<Style TargetType="ListBox">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"
VisibleChanged="onStackPanelVisibilityChange"
Loaded="onStackPanelLoaded"
VerticalAlignment="Center" HorizontalAlignment="Center" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
您会注意到我在堆栈面板上有一些事件处理程序.这些是为堆栈面板中的项目设置动画,因此它们会依次淡入视图.事件处理程序实现为:
void onStackPanelLoaded(object sender, RoutedEventArgs e)
{
StackPanel panel = sender as StackPanel;
applySubItemAnimations(panel);
}
void onStackPanelVisibilityChange(object sender, DependencyPropertyChangedEventArgs e)
{
StackPanel panel = sender as StackPanel;
if (panel.IsVisible)
{
applySubItemAnimations(panel);
} …Run Code Online (Sandbox Code Playgroud) 我只是想知道是否有一种方法可以最大限度地减少我的应用程序中的代码混乱.
我编写的代码类似于:
private void btnNext_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
btnNext.Opacity = 1;
}
private void btnNext_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
btnNext.Opacity = 0.5;
}
private void btnShowAll_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
btnShowAll.Opacity = 1;
}
private void btnShowAll_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
btnShowAll.Opacity = 0.5;
}
private void btnPrev_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
btnPrev.Opacity = 1;
}
private void btnPrev_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
btnPrev.Opacity = 0.5;
}
private void btnSearch_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
{
btnSearch.Opacity = 1;
}
private …Run Code Online (Sandbox Code Playgroud) 通常我会尝试在这里很好地记录这个问题,并复制一些代码,这样当我链接到的URL以证明问题不再导致任何地方时,至少问题将有足够的代码在其中,以便有人阅读很久以后可能会遇到同样问题的人可以看到这个例子.但在这种情况下,我遇到的问题是如此具体......我不知道什么是错的,所以我不知道在这里复制什么代码.
我有一个div,不透明度设置为1,在另一个div中,不透明度设置为.5,以制作一个非常便宜的"灯箱"效果.至少在其他两个网站上,我完全按照完全相同的方式完成了这个问题,并且从未遇到过这个问题.事实上,如果我在Dreamweaver中打开一个新的HTML页面并尝试复制该问题,我就不能.我知道我必须忽略一些如此荒谬的简单,但......
有问题的网址是http://pmind.com/staging/123/dashboard.shtml
中间的白色框generate_window继承其父级(generate_window-wash)不透明度.
为什么?
我在一个页面上有三个图像,我想淡出未点击的元素.该脚本在第一个实例中工作,因此如果您单击一张图片,则另外两个淡出.如果您认为点击已经褪色的图片,那么所有发生的事情都是最后一个非褪色的图片也会消失,而不是100%不透明而其他两个褪色.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<style>
.opac {
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
border:thick;
}
</style>
<script>
$(document).ready(function(){
$('a.images').click(function()
{
$(this).siblings().stop().animate({opacity: 0.4}, 300);
$('a.images').click(function()
{
$not('this').stop().animate({opacity: 1.0}, 300);
});
});
});
</script>
</head>
html
<body>
<div id="images">
<a class="images" href="#"><img class="click" src="../appalachia.jpg" height="133" /><br/><br/></a>
<a class="images" href="#"><img class="click" src="../appalachia.jpg" height="133" /><br/><br/></a>
<a class="images" href="#"><img class="click" src="../appalachia.jpg" height="133" /><br/><br/></a>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我正在使用以下CSS代码:
.rounded_box{
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
width:850px;
padding:15px;
background-color:#80C1FF;
margin:0 auto;
color: #0D2E47;
font-family: Arial,Helvetica,sans-serif;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
/* background-color:rgba(255,0,0,255); */
}
.rounded_box h1{
opacity:1.0;
filter:alpha(opacity=100); /* For IE8 and earlier */
}
Run Code Online (Sandbox Code Playgroud)
而且我希望h1和其他元素为不透明的,在div里面有类rounded_box.但也使h1和其他元素透明,我不想要.
那么可以解决这个问题呢?
快速,是否可以使用javascript或其他东西使图像变暗?
我不需要鼠标悬停或任何东西,只是为了使图像显示为禁用(我可以使用样式标签更改它的不透明度吗?).
我该怎么办?
我将外部 div 的不透明度属性设置为 .5,并将内部 div 的不透明度值设置为 1,但它仍然完全透明
这是示例代码: HTML:
<div id="div1">
<div id="div2">
<div id="div3"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
#div1{
background: black;
opacity:.5;
width:300px;
height:300px;
}
#div2{
background:white;
width:150px;
height:150px;
opacity: 1;
}
#div3{
display: block;
width: 50px;
height: 50px;
opacity: 1;
background: black;
}
Run Code Online (Sandbox Code Playgroud)
那么问题出在哪里呢?或者我有什么想念的?帮我!
我有一张桌子,每当有人在一个单元格上盘旋时,我希望它变得不那么透明(不透明度是默认的0.85).这是我的代码:
$(document).ready(function(){
$("td").hover(function(){
$(this).fadeTo(700,1);
},function(){
$(this).fadeTo(500,0.85);
});
});
Run Code Online (Sandbox Code Playgroud)
编辑:似乎问题可能是当我悬停时没有任何东西被触发,即使我添加alert('hi')到该功能,也没有任何反应
编辑2:如果有人仍然读到这个问题,我相信当我问这个问题时它不起作用的原因是因为我是异步创建td元素而当页面加载时它们不存在.我相信我最终使用的是.on()而不是.hover().此外,褪色到1.0不透明度是期望的效果(它开始于0.85或0.5我忘了).感谢大家
我正在尝试在div中设置一个图像,该图像将在5秒内缓慢出现(不透明度从0到1).我有这个代码:
.fadeDivIn {
opacity: 1;
transition: opacity 5s ease-in;
-moz-transition: opacity 5s ease-in;
-webkit-transition: opacity 5s ease-in;
-o-transition: opacity 5s ease-in;
}
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚如何自动触发它.
我一直在使用CSS3关键帧转换到其他元素,理想情况下应用类似于不透明度的东西,但是已经碰到了一堵砖墙.有人可以帮忙吗?
我正在开发应用程序,它为数据库中的每一行创建一个新的wpf边框组件.这意味着我必须在C#而不是XAML中设置边框组件的样式(据我所知).除了尝试设置背景不透明度之外,样式都很好.
motherboards.Add(new Border());
Border moboBorder = motherboards[i];
moboBorder.Width = 150;
moboBorder.Height = 150;
moboBorder.BorderBrush = Brushes.Black;
moboBorder.Background = Brushes.White;
moboBorder.CornerRadius = new CornerRadius(10);
moboBorder.Margin = new Thickness(5);
moboBorder.BorderThickness = new Thickness(1);
Run Code Online (Sandbox Code Playgroud)
您可以像这样在XAML中调整背景不透明度
<Border BorderThickness="1" Height="100" Width="100">
<Border.BorderBrush>
<SolidColorBrush Color="Black" Opacity="0.7"/>
</Border.BorderBrush>
</Border>
Run Code Online (Sandbox Code Playgroud)
但正如我所说,我用C#而不是XAML创建组件.我想这是你在c#中设置值的方式
moboBorder.Background.Opacity = //Value
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚它需要什么样的价值,而不仅仅是一个直线数字,没有什么比我能看到的画笔更像是没有像新的Opacity()
我试过谷歌搜索,但一切都是关于设置整个元素的不透明度而不仅仅是它的背景.
opacity ×10
css ×6
c# ×3
javascript ×3
css3 ×2
jquery ×2
wpf ×2
button ×1
class ×1
html ×1
image ×1
listbox ×1
tabcontrol ×1
transparency ×1
transparent ×1
z-index ×1