【问题标题】:Change font and size, CSS更改字体和大小,CSS
【发布时间】:2018-07-05 15:07:19
【问题描述】:

我正在尝试使用 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>

【问题讨论】:

  • 您将 javascript 添加为您的标签,但我在这里没有看到任何 javascript。
  • 这个问题中没有包含 JavaScript。你为什么使用&lt;object&gt;?为什么没有font-size CSS 属性?
  • 另外,div 不能在 p 内。

标签: html css


【解决方案1】:

您好,如果您正在寻找一种仅更改尺寸的方法。这可能是一个解决方案,这将改变字体大小并使其缩放。取决于显示器。

<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>

【讨论】:

  • 您好,谢谢您的帮助,我需要更改“sub.txt”文件的大小和字母。我不知道这段代码是否有用。还是谢谢你。
  • 尝试在&lt;div&gt;下添加代码。你也不能在一个段落下有一个&lt;div&gt;(&lt;p&gt;)。切换它们。
【解决方案2】:

您的 css 选择器指定 &lt;p&gt; 需要类 'montserrat'。您需要&lt;p class="montserrat"&gt; 才能使其正常工作(或将选择器更新为仅p - 删除.montserrat)。我还更新了下面的标记,将 &lt;div&gt; 更改为 &lt;span&gt; 以确保有效性。

<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>

【讨论】:

  • 嘿,感谢您的帮助,我尝试这样做,但它仍然没有改变字母的大小或字体。
猜你喜欢
  • 2011-06-14
  • 1970-01-01
  • 2021-12-19
  • 2017-11-24
  • 1970-01-01
  • 2011-06-25
  • 2015-05-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多