编写登录界面样式

时间: 2023-07-05 20:17:25 浏览: 116
好的,以下是一个简单的登录界面样式代码示例: HTML代码: ``` <div class="login-form"> <h2>Login Form</h2> <form> <input type="text" placeholder="Username"> <input type="password" placeholder="Password"> <button type="submit">Login</button> </form> </div> ``` CSS代码: ``` .login-form { width: 300px; margin: 0 auto; text-align: center; } .login-form h2 { margin-top: 0; font-size: 24px; } .login-form input[type="text"], .login-form input[type="password"] { display: block; width: 100%; padding: 10px; margin-bottom: 20px; border-radius: 5px; border: 1px solid #ccc; } .login-form button[type="submit"] { display: block; width: 100%; padding: 10px; background-color: #428bca; color: #fff; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease; } .login-form button[type="submit"]:hover { background-color: #3071a9; } ``` 这段代码会生成一个简单的登录界面,包含用户名和密码输入框以及登录按钮。你可以根据自己的需要进行修改和调整。

相关推荐

txt
/MainFrame.java import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MainFrame extends JFrame implements ActionListener{ private Container cont; private JPanel panelMenu; private JPanel panelToolBar; private JPanel panelCompent; private JButton btnLeft; private JButton btnCenter; private JButton btnRight; private JButton btnBorder; private JButton btnGrid; private JLabel labHit; private JMenuBar menuBar; private JMenu menuOperation; private JMenu menuHelp; private JMenuItem mItemFlowLeft; private JMenuItem mItemFlowCenter; private JMenuItem mItemFlowRight; private JMenuItem mItemBorder; private JMenuItem mItemGrid; private JToolBar toolBar; private JButton tBtnLeft; private JButton tBtnCenter; private JButton tBtnRight; private JButton tBtnBorder; private JButton tBtnGrid; public MainFrame(){ this.setTitle("第一个界面"); this.setBounds(300, 300, 600, 450); this.setDefaultCloseOperation(this.EXIT_ON_CLOSE); cont = this.getContentPane(); // cont.setLayout(new GridLayout(3, 9)); cont.setLayout(null); initPanel(); initMenu(); initToolBar(); initCompent(); addMenu(); addCompent(); // addBorderCompent(); this.setVisible(true); } public void initPanel(){ panelMenu = new JPanel(); panelMenu.setLayout(new FlowLayout(FlowLayout.LEFT)); panelMenu.setBounds(0, 0, 600, 30); panelToolBar = new JPanel(); panelToolBar.setLayout(new FlowLayout(FlowLayout.LEFT)); panelToolBar.setBounds(0, 30, 600, 50); panelCompent = new JPanel(); panelCompent.setLayout(new GridLayout(3, 2)); panelCompent.setBounds(0, 80, 600, 350); cont.add(panelMenu); cont.add(panelToolBar); cont.add(panelCompent); } public void initMenu(){ menuBar = new JMenuBar(); menuOperation = new JMenu("布局操作"); menuHelp = new JMenu("帮助"); mItemFlowLeft = new JMenuItem("流式左布局"); mItemFlowLeft.addActionListener(this); mItemFlowCenter = new JMenuItem("流式居中"); mItemFlowCenter.addActionListener(this); mItemFlowRight = new JMenuItem("流式右布局"); mItemFlowRight.addActionListener(this); mItemBorder = new JMenuItem("边界布局"); mItemBorder.addActionListener(this); mItemGrid = new JMenuItem("网格布局"); mItemGrid.addActionListener(this); } public void initToolBar(){ toolBar = new JToolBar(); tBtnLeft = new JButton(new ImageIcon("COPY.jpg")); tBtnLeft.addActionListener(this); tBtnLeft.setToolTipText("流式左布局"); tBtnCenter = new JButton(new ImageIcon("HELP.jpg")); tBtnCenter.addActionListener(this); tBtnCenter.setToolTipText("流式居中"); tBtnRight = new JButton(new ImageIcon("find.jpg")); tBtnRight.addActionListener(this); tBtnRight.setToolTipText("流式右布局"); tBtnBorder = new JButton(new ImageIcon("CUT.jpg")); tBtnBorder.addActionListener(this); tBtnBorder.setToolTipText("边界布局"); tBtnGrid = new JButton(new ImageIcon("OPEN.jpg")); tBtnGrid.addActionListener(this); tBtnGrid.setToolTipText("网格布局"); toolBar.add(tBtnLeft); toolBar.add(tBtnCenter); toolBar.add(tBtnRight); toolBar.add(tBtnBorder); toolBar.add(tBtnGrid); panelToolBar.add(toolBar); } public void initCompent(){ btnLeft = new JButton("LEFT"); btnLeft.addActionListener(this); btnRight = new JButton("RIGHT"); btnRight.addActionListener(this); btnCenter = new JButton("CENTER"); btnCenter.addActionListener(this); btnBorder = new JButton("BORDER"); btnBorder.addActionListener(this); btnGrid = new JButton("GRID"); btnGrid.addActionListener(this); labHit = new JLabel("提示"); } public void addMenu(){ menuOperation.add(mItemFlowLeft); menuOperation.add(mItemFlowCenter); menuOperation.add(mItemFlowRight); menuOperation.add(mItemBorder); menuOperation.add(mItemGrid); menuBar.add(menuOperation); menuBar.add(menuHelp); panelMenu.add(menuBar); } public void addCompent(){ panelCompent.add(btnLeft); panelCompent.add(btnCenter); panelCompent.add(btnRight); panelCompent.add(btnBorder); panelCompent.add(btnGrid); panelCompent.add(labHit); } public void addBorderCompent(){ panelCompent.add(btnLeft, "West"); panelCompent.add(btnCenter, "Center"); panelCompent.add(btnRight, "East"); panelCompent.add(btnBorder, "North"); panelCompent.add(btnGrid, "South"); } public void actionPerformed(ActionEvent aEvt){ if((btnLeft == aEvt.getSource()) ||(mItemFlowLeft == aEvt.getSource()) ||(tBtnLeft == aEvt.getSource())){ panelCompent.setLayout(new FlowLayout(FlowLayout.LEFT)); labHit.setText("流式布局管理器左靠齐"); } else { if((btnRight == aEvt.getSource()) ||(mItemFlowRight == aEvt.getSource()) ||(tBtnRight == aEvt.getSource())){ panelCompent.setLayout(new FlowLayout(FlowLayout.RIGHT)); labHit.setText("流式布局管理器右靠齐"); } else { if((btnCenter == aEvt.getSource()) ||(mItemFlowCenter == aEvt.getSource()) ||(tBtnCenter == aEvt.getSource())){ panelCompent.setLayout(new FlowLayout(FlowLayout.CENTER)); labHit.setText("流式布局管理器中靠齐"); } else { if((btnBorder == aEvt.getSource()) ||(mItemBorder == aEvt.getSource()) ||(tBtnBorder == aEvt.getSource())){ panelCompent.setLayout(new BorderLayout()); addBorderCompent(); labHit.setText("边界布局管理器"); } else{ if((btnGrid == aEvt.getSource()) ||(mItemGrid == aEvt.getSource()) ||(tBtnGrid == aEvt.getSource()) ){ panelCompent.setLayout(new GridLayout(3, 2)); // addBorderCompent(); labHit.setText("网格布局管理器"); } } } } } } } //LoginFrame.java import javax.swing.*; import java.awt.*; import java.awt.event.*; class LoginFrame extends JFrame implements ActionListener{ private Container cont; private JLabel labUserName; private JLabel labPassword; private JTextField txtUserName; private JTextField txtPassword; private JButton btnOK; private JButton btnCancel; public LoginFrame(){ this.setTitle("登录界面"); this.setSize(300, 250); this.setLocation(300, 300); this.setDefaultCloseOperation(this.EXIT_ON_CLOSE); initCont(); initCompent(); addCompent(); this.setVisible(true); } public void initCont(){ cont = this.getContentPane(); cont.setLayout(null); } public void initCompent(){ labUserName = new JLabel("用户名:"); labPassword = new JLabel("密 码:"); txtUserName = new JTextField(); txtPassword = new JPasswordField(); btnOK = new JButton("登录"); btnCancel = new JButton("重置"); } public void addCompent(){ cont.add(labUserName); labUserName.setBounds(40,40,80,30); cont.add(labPassword); labPassword.setBounds(40,90,80,30); cont.add(txtUserName); txtUserName.setBounds(120,40,120,30); cont.add(txtPassword); txtPassword.setBounds(120,90,120,30); cont.add(btnOK); btnOK.addActionListener(this); btnOK.setBounds(60,170,80,30); cont.add(btnCancel); btnCancel.addActionListener(this); btnCancel.setBounds(160,170,80,30); } public void actionPerformed(ActionEvent aEvt){ if(aEvt.getSource() == btnOK){ if((txtUserName.getText().equals("denghong")) &&(txtPassword.getText().equals("123"))){ new MainFrame(); this.dispose(); } } else{ if(aEvt.getSource() == btnCancel){ labUserName.setText(""); labPassword.setText(""); } } } } //Test.java public class Test{ public static void main(String[] args){ new LoginFrame(); } }

最新推荐

recommend-type

matlab程序模拟单个正电荷电位下的电子轨迹.rar

1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
recommend-type

医药生物:创新药、“AI 医疗”有望引领医药产业新发展(1).pdf

医药生物:创新药、“AI 医疗”有望引领医药产业新发展(1)
recommend-type

飞利浦4H.09C02.A11电源板电路图.rar

飞利浦4H.09C02.A11电源板电路图
recommend-type

CRC校验日常学习笔记

CRC校验的原理和算法,CRC校验是网络通讯协议中常用校验算法
recommend-type

【2024首发原创】白鲨优化算法WSO-TCN-LSTM-Multihead-Attention负荷预测Matlab实现.rar

1.版本:matlab2014/2019a/2024a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 替换数据可以直接使用,注释清楚,适合新手
recommend-type

解决本地连接丢失无法上网的问题

"解决本地连接丢失无法上网的问题" 本地连接是计算机中的一种网络连接方式,用于连接到互联网或局域网。但是,有时候本地连接可能会丢失或不可用,导致无法上网。本文将从最简单的方法开始,逐步解释如何解决本地连接丢失的问题。 **任务栏没有“本地连接”** 在某些情况下,任务栏中可能没有“本地连接”的选项,但是在右键“网上邻居”的“属性”中有“本地连接”。这是因为本地连接可能被隐藏或由病毒修改设置。解决方法是右键网上邻居—属性—打开网络连接窗口,右键“本地连接”—“属性”—将两者的勾勾打上,点击“确定”就OK了。 **无论何处都看不到“本地连接”字样** 如果在任务栏、右键“网上邻居”的“属性”中都看不到“本地连接”的选项,那么可能是硬件接触不良、驱动错误、服务被禁用或系统策略设定所致。解决方法可以从以下几个方面入手: **插拔一次网卡一次** 如果是独立网卡,本地连接的丢失多是因为网卡接触不良造成。解决方法是关机,拔掉主机后面的电源插头,打开主机,去掉网卡上固定的螺丝,将网卡小心拔掉。使用工具将主板灰尘清理干净,然后用橡皮将金属接触片擦一遍。将网卡向原位置插好,插电,开机测试。如果正常发现本地连接图标,则将机箱封好。 **查看设备管理器中查看本地连接设备状态** 右键“我的电脑”—“属性”—“硬件”—“设备管理器”—看设备列表中“网络适配器”一项中至少有一项。如果这里空空如也,那说明系统没有检测到网卡,右键最上面的小电脑的图标“扫描检测硬件改动”,检测一下。如果还是没有那么是硬件的接触问题或者网卡问题。 **查看网卡设备状态** 右键网络适配器中对应的网卡选择“属性”可以看到网卡的运行状况,包括状态、驱动、中断、电源控制等。如果发现提示不正常,可以尝试将驱动程序卸载,重启计算机。 本地连接丢失的问题可以通过简单的设置修改或硬件检查来解决。如果以上方法都无法解决问题,那么可能是硬件接口或者主板芯片出故障了,建议拿到专业的客服维修。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

Java泛型权威指南:精通从入门到企业级应用的10个关键点

![java 泛型数据结构](https://media.geeksforgeeks.org/wp-content/uploads/20210409185210/HowtoImplementStackinJavaUsingArrayandGenerics.jpg) # 1. Java泛型基础介绍 Java泛型是Java SE 1.5版本中引入的一个特性,旨在为Java编程语言引入参数化类型的概念。通过使用泛型,可以设计出类型安全的类、接口和方法。泛型减少了强制类型转换的需求,并提供了更好的代码复用能力。 ## 1.1 泛型的用途和优点 泛型的主要用途包括: - **类型安全**:泛型能
recommend-type

cuda下载后怎么通过anaconda关联进pycharm

CUDA(Compute Unified Device Architecture)是NVIDIA提供的一种并行计算平台和编程模型,用于加速GPU上进行的高性能计算任务。如果你想在PyCharm中使用CUDA,你需要先安装CUDA驱动和cuDNN库,然后配置Python环境来识别CUDA。 以下是步骤: 1. **安装CUDA和cuDNN**: - 访问NVIDIA官网下载CUDA Toolkit:https://www.nvidia.com/zh-cn/datacenter/cuda-downloads/ - 下载对应GPU型号和系统的版本,并按照安装向导安装。 - 安装
recommend-type

BIOS报警声音解析:故障原因与解决方法

BIOS报警声音是计算机启动过程中的一种重要提示机制,当硬件或软件出现问题时,它会发出特定的蜂鸣声,帮助用户识别故障源。本文主要针对常见的BIOS类型——AWARD、AMI和早期的POENIX(现已被AWARD收购)——进行详细的故障代码解读。 AWARDBIOS的报警声含义: 1. 1短声:系统正常启动,表示无问题。 2. 2短声:常规错误,需要进入CMOS Setup进行设置调整,可能是不正确的选项导致。 3. 1长1短:RAM或主板故障,尝试更换内存或检查主板。 4. 1长2短:显示器或显示卡错误,检查视频输出设备。 5. 1长3短:键盘控制器问题,检查主板接口或更换键盘。 6. 1长9短:主板FlashRAM或EPROM错误,BIOS损坏,更换FlashRAM。 7. 不断长响:内存条未插紧或损坏,需重新插入或更换。 8. 持续短响:电源或显示问题,检查所有连接线。 AMI BIOS的报警声含义: 1. 1短声:内存刷新失败,内存严重损坏,可能需要更换。 2. 2短声:内存奇偶校验错误,可关闭CMOS中的奇偶校验选项。 3. 3短声:系统基本内存检查失败,替换内存排查。 4. 4短声:系统时钟错误,可能涉及主板问题,建议维修或更换。 5. 5短声:CPU错误,可能是CPU、插座或其他组件问题,需进一步诊断。 6. 6短声:键盘控制器错误,检查键盘连接或更换新键盘。 7. 7短声:系统实模式错误,主板可能存在问题。 8. 8短声:显存读写错误,可能是显卡存储芯片损坏,更换故障芯片或修理显卡。 9. 9短声:ROM BIOS检验错误,需要替换相同型号的BIOS。 总结,BIOS报警声音是诊断计算机问题的重要线索,通过理解和识别不同长度和组合的蜂鸣声,用户可以快速定位到故障所在,采取相应的解决措施,确保计算机的正常运行。同时,对于不同类型的BIOS,其报警代码有所不同,因此熟悉这些代码对应的意义对于日常维护和故障排除至关重要。