@font-face {
font-family: <YourWebFontName>
src: <source>[<format>][,<source>[<format>]]*
[font-weight: <weight>]
[font-style: <style>]
}
一般你在用电脑做手机网页的时候,浏览器显示的比例和手机的比例为50%,就是说你在浏览器上面正常的内容在手机上只有50%的整体大小适配,所以说在浏览器做调试的时候把预览图缩小50%,然后调试各种属性的大小,显示正常后放到手机上就完美了如何设置html字体
设置字体
html
body
A heading
A paragraph
/body
/html
设置文字尺寸
html
body
A heading
A paragraph
/body
/html
设置字体颜色
html
body
A heading
A paragraph
/body
/html
设置文字的字体、字体尺寸、字体颜色
html
body
hello world
/body
/html
如何设置Java对话框字体
两种办法可以解决:
一、使用简单的HTML语法可以控制文字的大小:
二、(推荐!)先看参数
JOptionPane.showMessageDialog(Component, Object, String, int)第二个参数为Object,我们可以用一个JLabel来替代以前的String,给JLabel一个Font就OK了。
import javax.swing.*
import java.awt.*
import java.awt.event.*
import java.awt.event.ActionEvent
public class Test {
JFrame frame
JButton button
Font font
public Test(){
font = new Font("宋体",0,12)
UIManager.put("Button.font",font)
UIManager.put("Label.font",font)
frame = new JFrame("Test")
button = new JButton("弹出")
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
JLabel l = new JLabel("用户名或密码错误 请重新输入")
JOptionPane.showMessageDialog(frame,l,"错误",JOptionPane.ERROR_MESSAGE)
}
})
frame.getContentPane().add(button)
frame.setSize(300, 200)
frame.setVisible(true)
}
public static void main(String[] args) {
new Test()
}
}