- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用背景图片制作网站:(CSS)
body {
text-align: center;
background-image: url("../img/clouds.jpg");
background-size: 100% 760%;
}
我还在页面顶部有这个:(HTML)
<div class="pageTitle">
<p>Title of Page basically</p>
</div>
(CSS)
.pageTitle {
font-size: 200%;
}
当我尝试增大字体大小时,背景图像也会变大(基本上看起来像是放大了)。
我想这与百分比的使用有关,但即使使用 em
符号或 px
我仍然得到相同的结果。如何在不改变背景图片大小的情况下使 pageTitle
变大?
似乎使它起作用的是将 background-size: 100% 760%;
更改为 background-size: 100% 250%;
(在我的例子中) ,但是,无论何时更改一个元素,它都需要作为一个整体进行修复。
代码片段:
var currentQuote = '';
var availableQuotes = [ 'bla','blo','ble','foo','bar'
];
function setRandomQuote() {
currentQuote = availableQuotes[Math.floor(Math.random() * availableQuotes.length)];
$('#quote').html(currentQuote);
$('#tweetQuote').attr('href', 'https://twitter.com/intent/tweet?text=' + currentQuote).attr('target', '_blank');
}
$(function () {
$('#randomQuote').click(function () {
setRandomQuote();
});
});
.w3-tangerine {
font-family: 'Tangerine', serif;
font-size: 200%;
margin-top: 10%;
margin-bottom: 5%;
}
body {
text-align: center;
background-image: url("https://images.pexels.com/photos/850674/pexels-photo-850674.jpeg?cs=srgb&dl=agriculture-animal-photography-animals-850674.jpg&fm=jpg");
background-size: 100% 250%;
}
p {
font-size: 100%;
}
#randomQuote, #tweetQuote {
margin: 3% 1% 3% 1%;
}
#quote {
margin: 2% 2% 2% 2%;
}
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Random Quote Generator</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<noscript>Sorry, your browser does not support JavaScript!</noscript>
</head>
<body>
<div class="w3-tangerine">
<p>Just Another Random Quote Generator</p>
</div>
<div id="quote">
Click on the button to generate a quote!
</div>
<div>
<input id="randomQuote" type="button" class="btn btn-primary" value="Generate a Quote!">
<a id="tweetQuote" class="btn btn-primary" href="#">Tweet this Quote <i class="fa fa-twitter"></i></a>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
最佳答案
没有设置 body
的 height
background
的 height
的百分比作为 contant 的 >height
。所以 760% background-height
是 text-height
*7.6。这就是为什么当你改变图像的大小时图像的大小也会变大..
你可以做的是设置
html, body{
height:100%;
}
然后它将计算整个页面大小的百分比(因此在您的情况下,您只会看到图像高度的 1/7.6)。
关于html - 属性 'font-size' 也会改变 'background-img' 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50232491/
我想替换每一个 带结束标记 字符串中的标记。该字符串实际上是一个 html 文档,其中 img 标记由我生成,并且始终如下所示: Src 是用户输入,所以它可以是任何东西。我做了一个正则表达式,不确
我使用数组通过 getElementsByClassName 存储我所有的 imgs。 我需要知道哪个 img 被点击或 mouseover/mouseout,所以我使用循环来检查哪个 img 被点击
我正在尝试使用图像制作一款类似 Match3 的游戏,但我无法进行比较。我正在为固定数量的 atm 执行此操作,只是为了让它正常工作,稍后应该在 foreach 循环中。如果有什么区别的话,该函数位于
我希望你能帮助我:) 我想定义 img 的高度,相对于图像的“实际”宽度。但宽度是动态的,因为它占父对象的百分比(wxample 的浏览器窗口)。 为什么我需要高度?:没有高度它工作正常,但我需要它,
我知道这个话题被讨论了很多,但我找不到任何适合我的解决方案。所以,我的代码大致是: var img =me.images[curID] var f = function() { var
我试图在一个页面上列出多个图像,但当您单击图像时,它会以模式打开。 它适用于第一张图片,但不适用于其他图片,我假设这是一个 JS 问题,我尝试设置一个空的 var,然后将其设置为获取元素 ID(每个
任务:我们正在通过 HttpWebRequest 抓取 HTML 内容(约 6,000 个调用)。该字符串经过修剪并存储在 SQL Server 2014 数据库中,以便作为 XML 进行处理。 问题
我从上面得到这个错误,不知道如何避免它。我的目的是获取屏幕截图,然后对其进行模板匹配,以查看此时屏幕上是否显示图标。到目前为止,它只是图标的位置。我的代码: #include "opencv2/hig
我有一个包含图像的容器,该图像是从应用程序加载的,因此容器的尺寸是已知的,而图像会有所不同。 我目前有以下 css: #secondary_photos { height: 100px; wi
我正在尝试设置一个随分辨率缩放但看起来仍然不错的页面背景..这就是我正在使用的.. 站点是http://www.gd-gaming.com/wordpress ,如果你用 Firebug 检查它,它只
目前我有 如何删除包装 img 标签的 p 标签? 所以我可以得到.. 最佳答案 使用 $('p > img').unwrap(''); 这将删除 img 周围的所有 p。您应该使用 cl
我想要动画 3 .svg图片: 和css : .sequence { position: relative; } .sequence img { position: ab
我有外部 RSS 提要填充以下重复出现的类 elements 。 {teaserImage} {teaserImage} {teaserImage} 我想简单地获取 :first 实例,该实例也是来自
这是一个独特的问题: 我不想使用浏览器 JavaScript 来解决这个问题,请继续阅读... 我要转换 通过编译应用程序( ng build 或 ng serve )到 Base64 img 标签,
悬停在 中的第一张图片上标记,我需要使用 CSS 增加第二张图片的不透明度。我试过使用 +和 ~运营商,无法让它发挥作用。任何帮助将不胜感激。 最佳答案 a:hover + img
我已经尝试解决这个问题有一段时间了,但我迷路了,有人吗? for(var i=0; i<10; i++) { var Img = new Image(); Img.onload = (
这就是我想要实现的目标: 当用户将鼠标悬停在较小的图像之一上时: 较小的图像 + 文本应替换较大的图像 + 文本。 当用户没有悬停时;将大集返回到其原始图像和文字。 这就是我到目前为止所拥有的。它没有
我知道如何在 php 中执行此操作,但我需要在 javascript/jquery 中完成此操作。 我正在尝试执行以下操作: $('#NewBox').html( $('#OldBox').html(
我正在使用一个 CMS (ExpressionEngine),它将段落标签包裹在图像周围。我正在使用响应式图像(最大宽度:100%),并且由于我还在段落上定义宽度,因此它会导致问题。我想使用 jQue
Tinymce 正在删除我的 img 结束标记并生成无效的 xhtml。 它变成了这个 进入这个 我也在使用 codemagic,但是在查看 html 时它仍然显示 .我也试过包括 , 但输出是
我是一名优秀的程序员,十分优秀!