Remove top margin above header R markdown/pagedown in html output - html

I'm using Pagedown to generate a one-page html document that I can easily print to PDF with formatting (starting from html_paged default pagedown format).
I want to adjust the margin of my documents so that I use the full page space, especially at the top of the page, but I cannot seem to alter the margins. For example, there is always a (large) top margin above the first header of my document resulting in a blank space in my final document.
I'm using customized CSS style sheet to style my document. Setting the margins to 0 in this sheet doesnt reduce the margin in my final output, though the rest of the styling works fine. The page space remains limited.
I tried using:
* {
margin:0;
padding:2;
}
or
header{
margin-top: 0;
}
or resetting the margins of basically every element I could think of.
But nothing seems to work. Does anyone know what might be the issue?

You need to adjust the page margins via the margin-box properties.
See here for details on adjusting the margins: https://pagedjs.org/documentation/5-web-design-for-print/#margin-size-property
Starting from the default css pagedown files, if you were adjusting the first page then you’d want to adjust the margins in this part of the default-page.css file:
page :first {
#top-left {
content: none;
}
#top-right {
content: none;
}
#bottom-right {
content: none !important;
}
background-image: var(--front-cover);
background-position: center;
background-size: contain;
background-repeat: no-repeat;
}
Here’s an example of custom page margins:
#page {
margin-top: 20mm;
margin-bottom: 25mm;
margin-left: 10mm;
margin-right: 35mm;
}

Related

How to reduce left margin on blogger

I don't have any experience with html or css, I recently started my blog: https://nataliaputilova.blogspot.com/2019/09/blog-post_50.html
But you can see there's so much white space on the left, how do I reduce this? I tried googling some stuff about editing the html or adding a css code, but none of it worked.
This is the css I tried, and it didn't look like it changed anythin
.content-outer {
margin-left: 10px;
}
change the .centered-bottom and post-sidebar class width.
.centered-bottom, .centered-top {
width: 90%; /*change this */
}
if you don't want to have padding for .post-sidebar u can remove it.
.post-sidebar {
box-sizing: border-box;
display: block;
font: normal 400 14px Montserrat, sans-serif;
padding-right: 20px; /*Remove this if u don't want to have padding */
width: 70px; /*change this */
}
Final output:
It looks like sidebar (.post-sidebbar) is causing the main content to shift to the right. If it works, you can position it elsewhere so that your content gets more space.
OR
You can override the css of .centered-bottom, and add margin-left: 100px (Change the number as per your need) to it.

CSS Print and #page are not working

I have a simple HTML page and on that, I have
body, html {
width: 100%;
margin: 0;
padding: 0;
}
#media print {
#page {
size: letter portrait;
padding-left: 5in;
padding-right: 0.25in;
padding-top: 1in;
}
}
However, when I print preview in Chrome, it appears completely unaffected. What do I have to do to get Chrome to recognize the #page and the media query?
I don't think you need the media query because #page is only for print.
Also, according to: https://developer.mozilla.org/en-US/docs/Web/CSS/#page
You can only change the margins, orphans, widows, and page breaks of
the document. Attempts to change any other CSS properties will be
ignored.
Maybe using margins instead of padding would work.

Floating .field-item image to left of content type rather than centering it In Drupal

I'm relatively new to Drupal and so-so with CSS and am trying to float the image on a particular content type to the left of the content rather than having it center on the page on a row by itself. The purpose of the page is to have a list of items (like a catalog) and have an image to the left with the various descriptive fields to the right.
Using what I've found online I was able to get this on my CSS which almost works but after the first line being properly located to the right of the image the next line appears below the image. I would like all of them to be to the right, next to the image.
Because Drupal is generating the code I don't have the ability to easily change the HTML (though with work this is theoretically possible) but changes in the CSS are simple
.field-item img {
/* Shift "thumbail" images to the left */
/* new code to shift image to the left */
float: left;
padding-right: 10px;
/* -- old code to center image
margin-left: auto;
margin-right: auto;
*/
}
My theme is derived from danland. The page itself can be seen at http://blog.creatingorigami.com/content/eric%E2%80%99s-lotus
Any leads would be greatly appreciated!
Why change html code? This is crap. You can full styling html for use css styles.
I dont know if I understand right. This problem is clearfix hack, your page contains clearfixs.
Fastest solution.Change css property clear from both on value inherit.In system css called system.base.css. Path something as ..(root)/modules/system/.etc
After will be all contains on right side.
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: inherit; /*changed property!*/
visibility: hidden;
}
Comfortable, but not clean solution is violent rewrite property
to the root css style.
.clearfix:after {
clear: inherit !important;
}

CSS puzzle: How to add background-image and set height/width on empty span?

I've set background-image on a couple of span elements, but they aren't showing up, I think because my height and width settings are being ignored.
HTML source:
<div class="textwidget">
<span id="starthere" class="sidebar-poster"></span>
<span id="#primarydocs" class="sidebar-poster"></span>
<span id="donate" class="sidebar-poster"></span>
</div>
CSS:
span.sidebar-poster {
margin-bottom: 10px;
background-repeat: no-repeat;
width: 160px;
}
span#starthere {
background-image: url(/betatesting/wp-content/themes/dynamik/css/images/brunelwantsyou180.jpg);
height: 285px;
}
span#starthere:hover {
background-image: url(/betatesting/wp-content/themes/dynamik/css/images/brunelwantsyou_hover.jpg);
}
span#primarydocs {
background-image: url(/betatesting/wp-content/themes/dynamik/css/images/brunelwantsyou180.jpg);
height: 285px;
}
span#primarydocs:hover {
background-image: url(/betatesting/wp-content/themes/dynamik/css/images/brunelwantsyou_hover.jpg);
}
span#donate {
background-image: url(/betatesting/wp-content/themes/dynamik/css/images/donatebutton.jpg);
height: 285px;
}
span#donate:hover {
background-image: url(/betatesting/wp-content/themes/dynamik/css/images/donateposter_hover.jpg);
}
None of the background images are actually visible.
In Chrome Developer Tools, Under Computed Style, these two spans do appear to have a background image. If I copy and paste the URL of this image, I see the image. Yet nothing is actually rendering.
[UPDATE - this part is solved, thanks] In Chrome Developer Tools, under Matched Rules, only the #starthere and #donate spans are actually picking up the background-image attribute. The #primarydocs span is not. Why not?
SPAN is an inline element. Which will indeed ignore such things. Try setting the display mode in your CSS to something like: display: block;
I think your spans need to have display:inline-block, an ordinary span will always have its 'natural' width and height.
Since a is display: inline; automatically it cannot take width and height attributes from CSS.
If you want to use the inline characteristic but without inner content (ie: <span>content</span>) and instead have a background image, use padding instead.
ie:
span {
padding: 10px;
}
but input the number of pixels you would need to show the image.
Solved it - you can't set height and width on span because it is an inline element. Switching to div solved it.
Phew.
If anyone knows how to debug CSS with better tools than guesswork, hope, Google searches and swearing, please let me know!

How to show an image on html page using only css?

I want to show images on the page but I don't want to hardcode the references to the images in html.
Is it possible to do something like:
HTML:
<span id="got-easier"></span>
CSS:
#got-easier { image: url(/i/trend-down.gif); }
(IE6 should be supported)
Yes, use a background image :)
#got-easier { background-image: url(/i/trend-down.gif); }
Remember to set a span to display: block; and set width/height of your image if you use it.
As David Dorward pointed out, if it's an image relevant to the information, it should be included in the document with an <img> tag and alt attribute.
Heya, the common term for it is css Image Replacement technique (or IR). Here are the commonly used methods currently. Just choose any of the two ;)
/* Leahy Langridge Method */
span#imageName {
display: block;
height: 0 !important;
overflow: hidden;
padding-top: 0px; /* height of image */
width: 0px; /* width of image */
background: url(url/of/image.jpg) no-repeat
}
/* Phark Method */
span#imageName {
display: block;
width: 0px;
height: 0px;
background: url(url/of/image.jpg) no-repeat;
text-indent: -9999px
}
In case you want to display the images inline, position:absolute does the trick:
#got-easier {
display:inline;
position:absolute;
width:img-Xpx;
height:img-Ypx;
background:url(/i/trend-down.gif) no-repeat;
}
The only problem with this is that, since the image position is absolute, it will overlay whatever is next to it (in IE6 it might appear behind), and the workarounds that I found to fix this (with both CSS and jQuery) aren't supported in IE6. Your image-container will have to be followed by new line.
This might be useful when, for instance, you'd like to place a (?) image next to a form caption or a button (that usually have nothing next to them) to display help with onmouseover.