I want to write a div for every print page. So i did height of div 100%. Normally in every browser it is working well. But when i print this page it is not working in Chrome.
<!DOCTYPE HTL>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<meta name="googlebot" content="noindex">
<meta http-equiv="cache-control" content="no-cache">
<title>Brove.NET ISO Yazılımı</title>
<style>
html,body{
padding:0;
margin:0;
height:100%;
width:100%;
}
.sayfa{
height: 100%;
width: 768px;
}
</style>
</head>
<body>
<div class="sayfa" style="background-color:#666666">fds</div>
<div class="sayfa" style="background-color:#cccccc">fds</div>
<div class="sayfa" style="background-color:#aaaaaa">fds</div>
<script type="text/javascript" src="js/jquery-1.5.2.min.js"></script>
</body>
</html>
This is solution, man...
Try this code that is
#media print and (-webkit-min-device-pixel-ratio:0) {
.sayfa{
height: 1101px;
width: 768px;
}
}
This CSS/Chrome issue has been gone over here:
height 100% in chrome
Hope this helps.
Set the width and height of your html and body elements to 100%:
<style>
html {
width: 100%;
height: 100%;
}
body {
width: 100%;
height: 100%;
}
</style>
I can't find any documentation on this bug, but it's definitely a bug, no doubt about it.
Your code will execute perfectly in non-Webkit browsers (I'm assuming Safari does the same thing) and shows up fine on the screen, then goes into a magic can of fail upon clicking print, right? What's a guy to do?
Answer, give the HTML and BODY tags a defined height in an "actual" measurement, not percents:
html, body {
margin: 0;
padding: 0;
/* etc */
height: 880px;
}
div.sayfa {
height: 33%;
}
The pages print the same from Firefox 14 and Chrome 19+ using the styles above.
My experiments yielded a printed-page height of 880 pixels for the printer we were using, your mileage will probably vary. EMs work, too, but that caused too many headaches, so I figure a definitive pixel value would work best.
It's a messy workaround, but at least it actually works.
Related
I can't see some icons on my html using IE11.
This is the css code for the icon
.icon_sms:before {
display: block;
content: '';
height: 8em;
width: 8em;
vertical-align: middle;
background-repeat: no-repeat;
background-image:
url([...]);
}
I've tried also with display: inline-block, but it doesn't work either.
Also with no-cache property on html head
And also with
<meta http-equiv="X-UA-Compatible" content="IE=edge">
on first property on head
Any suggestion?
Thank you so much
Best regards
I think you can not use pseudoelements in IE11. To know what technology you can use in each browser, i recommend the web caniuse. It's very clear with a lot of technologies.
You can see the browsers that accept the before pseudoelement in this link. I hope that you will be useful.
According to your description and the code you provided, I did a simple test and found that it works fine in IE11.
A simple test:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style>
.icon_sms:before {
display: block;
clear: both;
content: '';
height: 40em;
width: 40em;
vertical-align: middle;
background-repeat: no-repeat;
background-image: url(https://i.stack.imgur.com/UzYKM.gif);
}
</style>
</head>
<body>
<div class="icon_sms" style="border:1px solid red">some text</div>
</body>
</html>
Because you haven't posted the image url and any html code yet. I guess it may be because the size in the before style is not large enough to display the image.
Try to modify the height and width in the example to 8em, it will not be displayed.
If you can post relevant complete examples, it will help solve the problem, thank you for your understanding.
I'm relatively new to Front End development, and have been trying to improve my core CSS skills.
I've come across a quirk between Edge (Chromium) and Chrome which does not make much sense to me.
I've attached two images of the same example index.html page opened in both Edge and Chrome.
You can see that in Chrome the text fits fine, but in Edge the text is cut in half! Does Edge do something different with the top margins?
Here is my attached HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./assets/css/style.css" type="text/css">
<title>Hello World</title>
</head>
<body>
<header>Hello, World!</header>
</body>
</html>
And the css:
html, body {
margin: 0;
padding: 0;
}
body {
background-color: #FFFFFF;
width: 100vw;
}
header {
background-color: rgb(115, 165, 216);
}
header {
width: 100vw;
height: 60px;
}
Thanks for your help! :)
This has me stumped. This works fine in browsers (tested Chrome, Firefox, and Safari), but doesn't work in Chrome emulator, Chrome mobile, or Firefox mobile.
<!DOCTYPE html>
<html lang="en">
<head>
<meta title="viewport" content="width=device-width, initial-scale=1.0">
<style>
div {
width: 50%;
float: left;
}
#media screen and (max-width: 500px) {
div {
width: 100%;
}
}
</style>
</head>
<body>
<div>Left</div>
<div>Right</div>
</body>
</html>
My original problem was more complex, but even boiling it down to the simplest form it's not working. Tried the above with different combinations such as display: inline-block; instead of float: left;, different viewport meta tags, adding only screen to the media query, other tags than plain divs, etc.
My original problem surfaced when doing work with Web Components + ShadowDOM, but it doesn't seem to be related to those. Made sure to bust all my caches while testing.
Am I going nuts?
Oh wow I'm dumb. Had a typo in the meta tag. Should be name instead of title:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
I'm using Chromium Version 51.0.2704.63 (64-bit)
<html>
<head>
<style>
html, body {
margin: 0;
}
div {
background-color: black;
height: 100px;
width: 50vw;
max-width: 100vw;
min-width: 360px;
}
</style>
<body>
<div></div>
</body>
</html>
Try pasting this markup into notepad, save as a .html file and run it.
Go into Chrome's device toolbar and choose Lumia 950
2 things you'll notice:
- In the developer tool's box model view, you'll see the dimensions are 490x100
- In the device toolbar, you'll see that the screen is 360x640
So what is going on here?
So is 490 the new 180?
You are missing
<meta content="initial-scale=1.0, width=device-width" name="viewport">
In your <head>.
Devtools is not broken, it's just simulating the the actual pixels you get on some of the mobile phones.
I have here my codes for html and css. I dont seem to catch the problem on why my images wont load or show-up. I tried them to load both on firefox and chrome.
My problem is not on jsfiddle.
And here is my folder structure:
localhost/website/img
localhost/website/css
localhost/website
http://jsfiddle.net/p8eS3/1/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="description" />
<meta name="author" content="author" />
<link href="css/index.css" rel="stylesheet" type="text/css" />
<title>Title</title>
</head>
<body>
<div id="container">
<div id="sidebar">
<div id="logo"></div>
</div>
</div>
</body>
</html>
#charset "utf-8";
/* Body */
#body {
font-family: Arial, Helvetica, sans-serif;
margin: 0px;
padding: 0px;
background: #ccc;
}
/* Container */
#container {
width: 100%;
background: #000;
}
/* Sidebar */
#sidebar {
background: url(../img/sidebar.png) repeat-y;
width: 40%;
float: left;
position: fixed;
}
/* Logo */
#logo {
background-image: url(../img/logo.png);
}
You have two images, they're added as background images for divs, but those divs do not have layout since the sidebar lacks height and the logo height and width. Which means they do not show up at all. Give them height/width to fix it.
If not the paths to the images are wrong.
The images aren't loading as jsfiddle won't recognise ../img/sidebar.png as this will look locally on their server.
I'm assuming that this is not your initial problem though, and that you are experiencing problems getting the right path on your application.
I would recommend 'rooting' your image url so that it works from the root folder to the location like:
background: url(/img/sidebar.png) repeat-y;
Could be your folder structure. Are the images in a folder the same level as your html file, or a level up. If they're the same level, try replacing ../images with ./images
Your path to the images is most likely off. This will be hard to debug via a js fiddle. Can you post your directory structure?
It's because your divs don't actually take up any space, so you can't see any background. See your modified fiddle for an example of how to fix this.
Alternatively, you might want to consider using HTML img tags.
You have to specify a width and a height to your #logo element so that the BG can appear.
Try,
#sidebar {
background: url(../img/sidebar.png) repeat-y;
width: 40px; /* your background width */
height:60px; /* your background height */
float: left;
position: fixed;
}
/* Logo */
#logo {
background: url(../img/logo.png) 0 0 no-repeat;
width: 40px; /* your logo width */
height:60px; /* your logo height */
}