flex---->样式和主题

 样式

样式对于一个应用程序来说也是非常有用的,使用样式和主题可以改变单个组件或者全部组件的外观,使他们看起来更加舒服。使用样式、使用字体、指针管理

一、使用样式
通过样式属性可以更改Flex组件的外观,这些属性包含了文字大小、背景颜色等定义。定义样式属性可以有几种方法,包括内部定义、设置组件样式属性、通过外部样式表文件等。

1.1 使用Style组件定义样式
通过<mx:Style>标记,可以定义CSS 2.0的语法。可以把定义的这些样式应用到当前文档或者其子文档。使用<mx:Style>标记定义样式的格式如下所示。

<mx:Style>
selector_name
{
style_property: value;
[...]
}
</mx:Style>

其中,selector_name是样式名称,style_property是样式属性,value是属性的值。这些都是严格遵循CSS 2.0的语法。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Style>
		Button 
		{
			fontSize: 15;
			color: #B3381A;
		}
	</mx:Style>
	<mx:Button id="myButton" label="按钮1" x="150" y="50"/>
	<mx:Button id="myButton2" label="按钮2" x="50" y="50"/>
</mx:Application>

1.2 使用StyleManager类定义样式
在ActionScript中使用StyleManager类,可以使用类的选择器设置样式。使用StyleManager类,还可以声明新的CSS样式,并且应用到Flex程序中的控件。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 creationComplete="initApp(event)">
 <mx:Style>
  .myStyle 
  {
   color: #FFFFFF;
  }
 </mx:Style>
 <mx:Script>
  <![CDATA[
   import mx.styles.StyleManager;
   
   public function initApp(e:Event):void 
   {
    // 设置 Button 控件的字体代谢哦啊
    StyleManager.getStyleDeclaration("Button").setStyle("fontSize",24);
    // 设置 myStyle 样式类的 color 值
    StyleManager.getStyleDeclaration(".myStyle").setStyle("color",0xB3381A);
    // 设置全局样式
    StyleManager.getStyleDeclaration("global").setStyle("fontStyle","italic");
   }
  ]]>
 </mx:Script>
 <mx:Button id="myButton" label="按钮1" styleName="myStyle" x="20" y="39"/>
 <mx:Label id="myLabel" text="这是一个文本标签." x="123" y="41" styleName="myStyle"/>
</mx:Application>

1.3 外部样式表
Flex同HTML一样,也支持外部的CSS样式表。使用<mx:Style>标记中的source属性,可以把外部的样式表应用到当前文档或者其子文档中。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Style source="style.css"/>
	<mx:Button id="myButton" label="按钮" x="68" y="41"/>
</mx:Application>

二、 使用字体
在应用程序中可以包含字体。包含的字体既可以是默认操作系统内置的,还可以是其他的外部字体。如果使用非系统默认的,那么就需要嵌入到应用程序中。
2.1 使用系统字体
通过fontFamily属性,可以把任何一个字体应用到程序中。然而,并不是所有的系统拥有所有的字体。系统字体并不能以外部信息的形式导出来,也不能嵌入在SWF文件中一起发布。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Style>
		VBox 
		{
			fontFamily: 微软雅黑;
			fontSize: 14pt;
		}
		
		Panel 
		{
			paddingLeft: 10;
			paddingTop: 10;
			paddingBottom: 10;
			paddingRight: 10;
		}
	</mx:Style>
	
	<mx:Panel title="字体显示面板" x="10" y="10">
		<mx:VBox>
			<mx:Button label="这个按钮使用了微软雅黑"/>
			<mx:Label text="这个文本使用微软雅黑"/>
			<mx:TextArea height="75">
			<mx:text>
				这个文本域使用了微软雅黑
			</mx:text>
			</mx:TextArea>
		</mx:VBox>
	</mx:Panel>
</mx:Application>

2.2 使用嵌入式字体
相比较使用系统字体,嵌入式字体的优势在于在程序运行时,指定的字体总是显示出来,不管系统中是否有这种字体。开发时不用去考虑字体样式丢失的问题。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Style>
		@font-face 
		{
			src: url("assets/msyh.ttf");
			fontFamily: myFontFamily;
			advancedAntiAliasing: true;
		}
		VBox 
		{
			fontFamily: fontFamily;
			fontSize: 14pt;
		}
		
		Panel 
		{
			paddingLeft: 10;
			paddingTop: 10;
			paddingBottom: 10;
			paddingRight: 10;
		}
	</mx:Style>
	
	<mx:Panel title="嵌入式字体" x="10" y="10">
		<mx:VBox>
			<mx:Button label="这个按钮嵌入了微软雅黑"/>
			<mx:Label text="这个文本嵌入了微软雅黑"/>
			<mx:TextArea height="75">
			<mx:text>
				这个文本域嵌入了微软雅黑
			</mx:text>
			</mx:TextArea>
		</mx:VBox>
	</mx:Panel>

</mx:Application>

三、 指针管理器
在Flex中,使用指针管理器可以控制鼠标指针的图片。当程序等待进程到完成的过程中,可以使用指针管理器提供一个用户提示。这些图片类型可以包括JPEG、GIF、PNG以及SVG等,还可以是一个Sprite对象,或者一个SWF文件。
指针管理器是放在包mx.managers.CursorManager中的,通过CursorManager类的静态属性和方法就可以控制鼠标指针的样式。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Script>
		<![CDATA[
			import mx.managers.CursorManager;
			import flash.events.*;
			// 定义指针变量ID
			private var cursorID:Number = 0;
			// 嵌入等待图片
			[Embed(source="assets/wait.gif")]
			private var waitCursorSymbol:Class;
			// 加载图片
			private function initImage(event:MouseEvent):void 
			{
				// 设置光标忙碌状态
				cursorID = CursorManager.setCursor(waitCursorSymbol);
				// 加载图片
				image1.load("http://pic.nipic.com/2008-03-10/200831013447396_2.jpg");
			}
			// 完成图片加载,移除指针样式
			private function loadComplete(event:Event):void
			{
				CursorManager.removeCursor(cursorID);
			}
		]]>
	</mx:Script>
	<mx:VBox x="36" y="23">
		<!-- 按钮触发图片加载 -->
		<mx:Button id="myButton" label="加载图片" fontSize="14" click="initImage(event);"/>
		<!-- 图像控件 -->
		<mx:Image id="image1"
			scaleContent="true"
			complete="loadComplete(event);"/>
	</mx:VBox>
</mx:Application>

 

<template> <div :class="prefixCls" class="relative h-[100%] lt-md:px-10px lt-sm:px-10px lt-xl:px-10px lt-xl:px-10px" > <div class="relative mx-auto h-full flex"> <div :class="`${prefixCls}__left flex-1 overflow-y-auto`" > <!-- 左上角的 logo + 系统标题 --> <div class="relative flex items-center text-white"> <img alt="" class="mr-10px h-160x w-160px" src="@/assets/imgs/logo1.png" /> <!-- <span class="text-20px font-bold">{{ underlineToHump(appStore.getTitle) }}</span>--> </div> <!-- 左边的背景图 + 欢迎语 --> <div class="h-[calc(100%-60px)] flex items-center justify-center"> <TransitionGroup appear enter-active-class="animate__animated animate__bounceInLeft" tag="div" > <div key="2" class="text-3xl text-white">欢迎使用数字化工厂智慧平台</div> <div key="3" class="mt-5 text-14px font-normal text-white"> </div> </TransitionGroup> </div> </div> <div class="relative flex-1 p-30px dark:bg-[var(--login-bg-color)] lt-sm:p-10px overflow-x-hidden overflow-y-auto" > <!-- 右上角的主题、语言选择 --> <!-- <div--> <!-- class="flex items-center justify-between at-2xl:justify-end at-xl:justify-end"--> <!-- style="color: var(--el-text-color-primary);"--> <!-- >--> <!-- <div class="flex items-center at-2xl:hidden at-xl:hidden">--> <!-- <img alt="" class="mr-10px h-48px w-48px" src="@/assets/imgs/logo1.png" />--> <!-- <span class="text-20px font-bold" >{{ underlineToHump(appStore.getTitle) }}</span>--> <!-- </div>--> <!-- <div class="flex items-center justify-end space-x-10px h-48px">--> <!-- <ThemeSwitch />--> <!-- <LocaleDropdown />--> <!-- </div>--> <!-- </div>--> <!-- 右边的登录界面 --> <Transition appear enter-active-class="animate__animated animate__bounceInRight"> <div class="m-auto h-[calc(100%-60px)] w-[100%] flex items-center at-2xl:max-w-500px at-lg:max-w-500px at-md:max-w-500px at-xl:max-w-500px" > <!-- 账号登录 --> <LoginForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" /> <!-- 手机登录 --> <MobileForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" /> <!-- 二维码登录 --> <QrCodeForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" /> <!-- 注册 --> <RegisterForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" /> <!-- 三方登录 --> <SSOLoginVue class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" /> <!-- 忘记密码 --> <ForgetPasswordForm class="m-auto h-auto p-20px lt-xl:(rounded-3xl light:bg-white)" /> </div> </Transition> </div> </div> </div> </template> <script lang="ts" setup> import { underlineToHump } from '@/utils' import { useDesign } from ‘@/hooks/web/useDesign’ import { useAppStore } from ‘@/store/modules/app’ import { ThemeSwitch } from ‘@/layout/components/ThemeSwitch’ import { LocaleDropdown } from ‘@/layout/components/LocaleDropdown’ import { LoginForm, MobileForm, QrCodeForm, RegisterForm, SSOLoginVue, ForgetPasswordForm } from ‘./components’ defineOptions({ name: ‘Login’ }) const { t } = useI18n() const appStore = useAppStore() const { getPrefixCls } = useDesign() const prefixCls = getPrefixCls(‘login’) <style lang="scss" scoped> $ prefix-cls: #{$ namespace}-login; .#{$ prefix-cls} { overflow: auto; &__left { &::before { position: absolute; top: 0; left: 0; z-index: -1; width: 100%; height: 100%; background-image: url('@/assets/svgs/login-bg.svg'); background-position: center; background-repeat: no-repeat; content: ''; } } } </style> <style lang="scss"> .dark .login-form { .el-divider__text { background-color: var(--login-bg-color); } .el-card { background-color: var(--login-bg-color); } } </style> 插入一张newlogo.png的背景图100%平铺作为背景,左右都要,整个的
最新发布
07-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值