简体   繁体   English

删除蒸馏网站明信片上照片顶部和导航栏之间的空间

[英]Remove space between top of photo and navbar on distill website postcards

I have built a website -- j-dunning.net -- using distill for R Markdown.我已经建立了一个网站 - j-dunning.net - 使用 R Markdown 的蒸馏。 Although I can tweak the CSS code for the website generally, how can I tweak the postcard landing page in isolation?虽然我通常可以调整网站的 CSS 代码,但如何单独调整明信片登录页面?

I would specifically like to remove of the space between the nav bar and the top of my image, and, change the colour of the hyperlink at the foot of the bio.我特别想删除导航栏和图像顶部之间的空间,并更改生物底部超链接的颜色。

Any help welcome欢迎任何帮助

Jamie杰米

Global versus local styles全局与本地 styles

For an all across the site change, add a style sheet to _site.yml.对于整个站点的更改,将样式表添加到 _site.yml。 To change an individual page, add a style sheet to the individual page.要更改单个页面,请将样式表添加到单个页面。 With the library distill , you can run the function create_theme(name = themeMePlease) in the console.使用库distill ,您可以在控制台中运行 function create_theme(name = themeMePlease) It will create a.css style sheet in your project environment.它将在您的项目环境中创建一个.css 样式表。 It will have prefilled content, based on other elements you've indicated in your YAML (YAMLs...?), as well.它将根据您在 YAML(YAML ......?)中指示的其他元素预填充内容。

If you want the changes to be global (the whole website) add the theme to the _site.yml.如果您希望更改是全局的(整个网站),请将主题添加到 _site.yml。 Obviously include the name, title, and whatever other settings you have.显然包括名称、标题和您拥有的任何其他设置。 Just keep in mind this is not indented.请记住,这不是缩进的。 It should be flush left.它应该向左冲洗。

name: "siteDistill"
title: "Answering SOQ questions"
theme: themeMePlease.css

If you want to apply this style sheet to a specific page, add it to that page's YAML.如果您想将此样式表应用到特定页面,请将其添加到该页面的 YAML。 Don't add it to global and another page's YAML .不要将它添加到全局和另一个页面的 YAML You could add it to more than one page's YAML if it's not in the _site.yml.如果它不在 _site.yml 中,您可以将其添加到多个页面的 YAML。

To change the hyperlink color, open that style sheet.要更改超链接颜色,请打开该样式表。 At the bottom, add the following to control the settings for <a> tags.在底部,添加以下内容来控制<a>标签的设置。 (That's a hyperlink tag.) (这是一个超链接标签。)

/* Change link appearance */
d-article a {
  border-bottom: 2px solid #ffd8db;
  text-decoration: none;
  color: #B21E28;
}

That worked for everything except the postcards built about page.除了关于页面的postcards之外,这适用于所有内容。 Personal themes, global themes, and in-line styling won't work for this script.个人主题、全局主题和内嵌样式不适用于此脚本。 The only thing I found that worked was inline Javascript.我发现唯一有效的是内联 Javascript。

Take that postcards .postcards (I still win.) (我还是赢了。)


Reduce the whitespace between the postcard and the navigation bar减少明信片和导航栏之间的空白

In the RMarkdown script that you have your postcard in (most likely about.Rmd), add the following to add a margin to the bottom of the postcard.在您有明信片的 RMarkdown 脚本中(很可能是 about.Rmd),添加以下内容以在明信片底部添加边距。 You won't need to add any libraries, packages, et cetera for this to work.您无需添加任何库、包等即可使用。 The units em are relative, so it should work well when the screen size changes or if more content is added.单位em是相对的,因此当屏幕尺寸发生变化或添加更多内容时,它应该可以正常工作。 You can certainly change the units or amount.您当然可以更改单位或数量。 I will encourage you to avoid px and try to stick with vh , rem , or em , since they're relative sizes.我会鼓励您避免使用px并尝试坚持使用vhremem ,因为它们是相对大小。

```{r iWin,results="asis",engine="js",echo=FALSE}
// look for the element to modify
elem = document.querySelector('body > div > div > div');

sAdd = "padding-bottom: 15em;";  // this will be added
                         // em is relative, will adjust with other flexing

// extract any inline attributes already present
styler = elem.getAttribute("style");
if (styler==undefined || styler==null) {  // if there are no HTML styles set
      styler = "";  
}
elem.setAttribute("style",styler+sAdd);
```

Changing the Postcards about page hyperlink color更改有关页面超链接颜色的Postcards

To change the hyperlink color for the postcards generated script, use the following code.要更改postcards生成脚本的超链接颜色,请使用以下代码。 Change #B21E28 for the color you want.将#B21E28 更改为您想要的颜色。 I recommend using RGB, HSL, or HEX-coded colors.我建议使用 RGB、HSL 或 HEX 编码的 colors。

```{r iWinAgain,results="asis",engine="js",echo=FALSE}
// look for the element to modify
elem2 = document.querySelector('p > a');

sAdd2 = "color: #B21E28;";  // this will be added

// extract any inline attributes already present
styler2 = elem2.getAttribute("style");
if (styler2==undefined || styler2==null) {  // if there are no HTML styles set
      styler2 = "";  
}
elem2.setAttribute("style",styler2+sAdd2);
```

This is a snapshot using the default distill webpage and the default postcards build, perhaps some of your site content, along with the changes in this answer:这是使用默认提取网页和默认postcards构建的快照,可能是您的一些网站内容,以及此答案中的更改:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM