[英]SweetAlert2 crappy text
I have a question about SweetAlert2 .我有一个关于SweetAlert2的问题。 As you can see in this picture that's how my swal2 looks, but on the official site or others the text is smoother, how should I fix this?正如你在这张图片中看到的,这就是我的 swal2 的样子,但在官方网站或其他网站上,文字更流畅,我应该如何解决这个问题? Maybe I've forgot one CSS/JS?也许我忘记了一个 CSS/JS?
<!DOCTYPE html>
<html>
<head>
<title> test </title>
<link rel="stylesheet" type="text/css" href="css/sweetalert2.css">
<script>
function myFn(){
swal(
'Succes!',
'Mesajul a fost trimis cu succes!',
'success'
)
}
</script>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" src="js/sweetalert2.js"></script>
</body>
</html>
Screenshot: http://prntscr.com/jnoula Github / JSFiddle: http://prntscr.com/jnovyf截图: http ://prntscr.com/jnoula Github / JSFiddle: http ://prntscr.com/jnovyf
<?php echo '<script type="text/javascript">
myFn();
</script>'; ?>
SweetAlert2 doesn't define font-family but inherits it from the document . SweetAlert2 没有定义 font-family 而是从 document 继承它。 The reason is that alerts should look consistent with the rest of the page.原因是警报应该与页面的其余部分保持一致。
Define the font-family
for your page and you'll be fine :)为您的页面定义font-family
,您会没事的 :)
Demo with Ubuntu typeface:使用 Ubuntu 字体的演示:
Swal.fire({ title: 'So beautiful yet terrific!', icon: 'success' })
body { font-family: 'Ubuntu'; }
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.