[英]Change font and size, CSS
我正在嘗試使用HTML和CSS,讓程序讀取文本文件並將其寫在圖像上,我設法讀取了該文件,但是找不到改變字體,字母大小的方法,除其他事項外。
這是所有代碼。
<style type="text/css"> @font-face { font-family: "Montserrat"; src: url(https://fonts.googleapis.com/css?family=Montserrat:400,700) format("truetype"); } p.montserrat { font-family: "Montserrat", Verdana, Tahoma; } </style> <p style="overflow: hidden; float: left;"> <img style="margin: 0px 0px -74px 0px;" src="NewOverlay.png" /> <div style="position: absolute; top: 95px; left: 60px;"> <object type="text/plain" data="sub.txt" width="400" height="300"></object> </div> </p>
您的css選擇器指定<p>
需要類'montserrat'。 您需要<p class="montserrat">
才能正常工作(或將選擇器更新為p
刪除.montserrat
)。 我還更新了下面的標記,以將<div>
更改為<span>
以確保有效性。
<p class="montserrat" style="overflow: hidden; float: left;">
<img style="margin: 0px 0px -74px 0px;" src="NewOverlay.png" />
<span style="position: absolute; top: 95px; left: 60px;">
<object type="text/plain" data="sub.txt" width="400" height="300"></object>
</span>
</p>
您好,如果您正在尋找一種僅更改大小的方法。 這可能是一個解決方案,它將更改字體大小並使其縮放。 取決於監視器。
<style type="text/css">
@font-face {
font-family: "Montserrat";
src: url(https://fonts.googleapis.com/css?family=Montserrat:400,700)
format("truetype");
}
p.montserrat {
font-family: "Montserrat", Verdana, Tahoma;
font-size: 2vw;
/* This will make the font scale to 2% of width of the monitor.
You can also specify a second value: font-size: 2vh;
That would make it scale to the height of the monitor too
You could also tinker a bit with them together seperated by,
a comma.*/
}
</style>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.