Reputation: 919
I have tried to implement a responsive web page to view an image. In order to do that, I use HTML5. Below is an example code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<style type="text/css">
.center{margin: 0px auto; display: block;}
</style>
</head>
<body>
<picture>
<source media="print" srcset="https://www.mywebsiteurl/point_th@monochrome">
<source media="(max-width: 480px)"
srcset="https://www.mywebsiteurl/point_th@1x">
<source media="(max-width: 640px)"
srcset="https://www.mywebsiteurl/point_th@2x">
<source media="(max-width: 1024px)"
srcset="https://www.mywebsiteurl/point_th@4x">
<img src="https://www.mywebsiteurl/point_th@4x" class="center">
</picture>
</body>
</html>
And this is the view of website from my cellphone (Samsung Galaxy S6 Edger):
From the view of my cellphone, I see there is a white space around my picture. So how can I make it fit to the screen without white space?
Upvotes: 0
Views: 77
Reputation: 6645
I have the same answer as others have however i have one suggestion to add
Try using reset css or Normalize. Using any of these CSS files helps a lot especially in such case.
Codes mentioned in answer like
*{
margin:0;
padding:0;
}
are already there in these files. It has a lot more content that removes default styling of browsers and gives you a neat and clean way to define your own CSS.
Upvotes: 0
Reputation: 976
Try
* {
margin: 0;
padding: 0;
}
This will set the margin and padding of all elements to 0
but be sure this is the first thing in your CSS file.
You can also try
picture {
height: 100vh; // vh is viewport height
width: 100vw; // vw is viewport width
}
Upvotes: 2
Reputation: 42
Some browsers will have default body margin. u can remove it by:
body {
margin: 0px;
}
Upvotes: 0
Reputation: 10207
The must be the problem of body default spacing
body has a default spacing in every html page we need to set it to 0
body{
margin:0;
padding:0;
}
Upvotes: 1