Scaling HTML from transcribed PDF files - php

I have a few PDF files that were converted to HTML. I fully understand that this isn't ideal, but that's not something I can change.
The issue is that it places content at very specific points which breaks mobile responsiveness.
A typical HTML will looks like this:
<div class="pc pc1 w0 h0">
<div class="t m0 x0 h2 y1 ff1 fs0 fc0 sc0 ls0 ws0">Text</div>
</div>
And the CSS file like this:
#media screen and (-webkit-min-device-pixel-ratio:0){
.sc_{-webkit-text-stroke:0px transparent;}
.sc0{-webkit-text-stroke:0.015em transparent;text-shadow:none;}
}
.ws0{word-spacing:0.000000px;}
.fc0{color:rgb(35,31,32);}
.fs0{font-size:168.000000px;}
.y0{bottom:781.000000px;}
.h0{height:841.889770px;}
.w0{width:595.275630px;}
.x0{left:34.000000px;}
}
Is it possible to somehow make it scale? I'd even be happy(-ier) if I could just apply a media query to reduce everything in size by 20%.

As it appears from the posted CSS, position: absolute is used, so I can't see any other solution (yet) than using transform: scale() (if not to rewrite the html of course)
By using media query it could look like this
.outer {
height: 500px;
width: 800px;
background: red;
transform-origin: 0 0;
}
#media screen and (max-width: 1000px) {
.outer {
transform: scale(0.9);
}
}
#media screen and (max-width: 900px) {
.outer {
transform: scale(0.8);
}
}
#media screen and (max-width: 800px) {
.outer {
transform: scale(0.7);
}
}
height: 400px;
width: 600px;
}
<div class="outer"></div>

Related

How do I ensure that the images and text are responsive?

I want to have 3 movies per row and for the texts below to be on the centre relative to the image.
Currently, my website looks like this (please ignore the red box, it is just for me to see the size)
In addition, when I resize my page, the title and the texts get shifted all over. How do I prevent this from happening and ensure that everything is responsive?
Codes in PHP file:
<div class="col-md-3 row movieBox">
<img src="'.$sub_row["image"].'" class="img-responsive img-thumbnail"/>
<h4>'.$sub_row["title"].'</h4>
<p>'.$sub_row["movie_warning"].'</p>
<p>'.$sub_row["movie_duration"].'</p>
</div>
Codes in CSS:
.movieBox{
float: left;
display: flex;
padding: 50px;
margin: auto;
margin-bottom: 10px;
position: relative;
border: 1px solid red;
}
/*Responsive layout - makes a two column-layout instead of four columns */
#media screen and (max-width: 900px) {
.column {
width: 50%;
}
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
}
You do not need float: left; or position: fixed; on either selector.
Flex is attempting to fit as many boxes as possible in the available width. By default it will shrink the elements as much ass possible. To fix that you can add a width to your elements and use flex-wrap to make the content wrap.
Try something like this:
.Row{
display: flex;
border: 1px solid red;
flex-wrap: wrap;
justify-content: space-between;
}
.Column{
width: 33%;
flex-shrink: 0;
display: flex;
padding: 50px;
border: 1px solid red;
}
You should use CSS Grid to get the desired result. Firstly, create a three-column layout with:
.container {
display: grid;
grid-template-columns: repeat(3, 1fr); /*this will create 3 equal columns*/
grid-template-rows: auto;
grid-gap: 1em; /*add only if you want to add some space in between the red boxes*/
}
Adding this, the items inside container class will arrange themselves in rows of threes.
Now, for the responsiveness, use media queries.
#media screen and (max-width: 480px) {
.container {
grid-template-columns: 1fr; /*one-column for mobile devices*/
}
}
You need two steps:
1- Use flex layout or grid layout.
2- Use media queries.
This simple example may help you CSS Flex Responsive

Banners shows small on mobile and big on laptop

I have a banner code that shows banner image big enough correctly on my laptop screen but when I open the same web page on my mobile phone, it shows the banner very small in height making it narrow to read. how to resolve this issue so that I can make the banner remain the same size for laptop screen as it is currently now, but much bigger for the mobile screens?
HTML CODE:
<?php
echo "<div class=custom-banner><img src=https://www.garnfyndet.se/wp-content/uploads/2019/12/banner.gif></div>";
?>
.custom-banner {
background-position: center center;
position: relative;
box-sizing: border-box;
display: block;
z-index: 999;
}
<div class=custom-banner><img src=https://www.garnfyndet.se/wp-content/uploads/2019/12/banner.gif></div>
I'm using WordPress, so maybe it inherits some CSS properties from style.css of WordPress. Currently, the banner image size is 1950 x 75.
You need to set img width to 100% so it would be responsive. and css selector needs to be .custom-banner img
.custom-banner {
background-image: url('https://www.garnfyndet.se/wp-content/uploads/2019/12/banner.gif');
background-position: center center;
background-size: contain;
position: relative;
width: 100%;
height: 75px;
background-repeat: no-repeat;
}
}
#media only screen and (max-width: 800px) {
.custom-banner {
background-image: url('https://www.voicesofyouth.org/sites/default/files/images/2019-03/nature-3125912_960_720.jpg');
height:400px;
}
}
<div class=custom-banner></div>
Also you need to set another img with lower height for mobile this photo is not good for responsive mobile.
you can use cs like this for mobile and background image would be changed when device width is lower than 400px. For Example:
#media only screen and (max-width: 400px) {
.custom-banner {
background-image: url('https://www.voicesofyouth.org/sites/default/files/images/2019-03/nature-3125912_960_720.jpg');
}
}

Reducing White Space Above Your Header Image Regardless Of The Browser Size

My website is www.rosstheexplorer.com.
The following code is in my header.php
<img class="header-img" src="https://i2.wp.com/www.rosstheexplorer.com/wp-content/uploads/2017/02/Cover-Photo-6-2.jpg">
<img class="mobile-header-img" src="https://i2.wp.com/www.rosstheexplorer.com/wp-content/uploads/2017/05/Cover-Photo-Mobile-Test.jpg">
The following code is in Additional CSS
#media screen and (min-width: 660px) {
.mobile-header-img {
display: none;
}
}
#media screen and (max-width: 660px) {
.header-img {
display: none;
}
}
There is usually white space above the header image when viewing the site on desktops. It almost seems as if the white space stays even when the mobile image does not appear.
How can I ensure that there is never any gap between the header image and the top of the page.
Thank you
You have the following media query in custom-css:
#media screen and (min-width: 75em) {
.site {
max-width: 1153px;
margin: 400px auto;
padding: 54px 108px;
}
}
The 400px margin is responsible for your header image being pushed so far down the page. Simply remove this to ensure that the header stays at the top of the page.
Alternatively, you can use the shorthand margin of margin: 0 auto 400px; if you would like to keep the margin at the bottom, but remove the marign at the top.
Note that you also have a padding of 54px. If you would like it flush up against the top of the page, you can remove the padding as well, or use padding: 0 108px 54px; to only pad the bottom.
Hope this helps! :)
There is a margin in your .site-Class. It also seems that theses styles are duplicate in different files of your CSS (style.css and a ?cached? custom-css) .
Change your CSS and it should be as expected:
#media screen and (min-width: 75em) {
.site {
max-width: 1153px;
margin: 0 auto; /* change to this value or remove this line, it's already inherited from style.css:967 */
padding: 54px 108px;
}
}
Thank you for your suggestions.
In Additional CSS I had
#media screen and (min-width: 75em) {
.site {
max-width: 1153px;
margin: 400px auto;
padding: 54px 108px;
}
}
I have now changed it to
#media screen and (min-width: 75em) {
.site {
max-width: 1153px;
margin: -50px auto;
padding: 54px 108px;
}
}

Wordpress Sidebar showing in inspect on chrome but not on phone

I ran in to an issue.
I've made a custom sidebar for a website. this includes a search, a category list and a pricing option.
As you can see up here, it shows it perfectly when inspecting on google chrome.
But when I open the same page on my phone, it does not show up anymore.
This sidebar is supposed to be shown by using the following custom css :
#media only screen and (max-width: 759px) {
#sidebar {
position: absolute !important;
top: -9999px !important;
left: -9999px !important;
}
}
#media only screen and (max-width: 759px) {
#sidebar-3 {
display:block;
}
}
#media only screen and (min-width: 767px) {
#woocommerce_product_search_widget-8 {
position: absolute !important;
top: -9999px !important;
left: -9999px !important;
}
}
#media only screen and (min-width: 767px) {
#woocommerce_price_filter-10 {
position: absolute !important;
top: -9999px !important;
left: -9999px !important;
}
}
#media only screen and (min-width: 767px) {
#woocommerce_product_categories-4 {
position: absolute !important;
top: -9999px !important;
left: -9999px !important;
}
}
Which basically makes sure that on the desktop it has the sidebar on the left (sidebar). Which it hides on phones/tablets and such. And on phone it has the sidebar-3 on the top which is hidden on desktop.
As you can see I even tried to do it by showing sidebar-3 by adding display:block. Sadly to no avail.
I'm using the same code on two other website's, where they work perfectly.
Does anyone have any idea what might be going on here?

Why are my media queries not applying?

Edited to add, so no one else posts this as an answer: I already have a viewport tag in my code.
I have read many of the responses here to similar questions, and I'm sure my problem probably lies somewhere in the order that my queries are declared in, but I can't for the life of me figure out where.
Bootply example here.
I have two divs, one that should display in wide layouts, and one that should display in narrow layouts.
<!-- for small layouts -->
<div class="container-fluid slogan text-center" id="home-slogan-container-small">
small
</div>
<!-- for 800 px and wider -->
<div class="container-fluid slogan text-center" id="home-slogan-container-large">
large
</div>
(These are very stripped-down; the actual content has different layouts inside the divs.)
The problem I'm having is that, no matter what size I scale the browser to (tested in FF using ctrl-shift-m to get mobile view, and in Chrome using the mobile view button in the dev tools), the small layout displays.
Here's my css:
#home-slogan-container-small {
padding-top: 15px;
text-align: center !important;
display: none;
}
#home-slogan-container-large {
padding-top: 15px;
text-align: center !important;
display: none;
}
#media only screen and (max-width: 1500px) {
#home-slogan-container-small { display: none !important;}
#home-slogan-container-large { display: block !important;}
}
#media only screen and (max-width: 1200px) {
#home-slogan-container-small { display: none !important;}
#home-slogan-container-large { display: block !important;}
}
#media only screen and (max-width: 960px) {
#home-slogan-container-small { display: none !important;}
#home-slogan-container-large { display: block !important;}
}
#media only screen and (max-width: 800px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
#media only screen and (max-width: 799px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
#media only screen and (max-width: 420px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
#media only screen and (min-width: 300px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
I'm a PHP/mySQL developer who's had a bootstrap site dropped on me; CSS is not my strong suit. Any explanation would be appreciated.
Here's the problem
#media only screen and (min-width: 300px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
it's min-width... meaning anything with width greater than that (e.g. all browser) will have those properties be true. Change it to max-width and you'll be fine.
Edit: all of the below is true, but not the cause of #EmmyS problem. Solution is above.
I recently had this issue with Foundation, and I suspect bootstrap has the issue too. your html is probably missing a meta declaration:
<meta name="viewport" content="width=device-width, initial-scale=1">
add that into the head of your HTML and it will probably work fine. The reason you're having this problem is because the mobile browser is deciding "okay, I don't know how to display this website, so I'm going to scale it as if I was a large browser, even though I'm not."
you have to remove the last media query
#media only screen and (min-width: 300px) {
#home-slogan-container-small { display: block !important;}
#home-slogan-container-large { display: none !important;}
}
the reason is, that this last is the only with min-width rule and overrule that all before (except in the case of wieport < 300px)
Rewrite all styling like this:
/* Styles for size 0px - 799px */
.small {
display: block;
}
.middle {
display: none;
}
.large {
display: none;
}
/* Styles for size 800px - 1200px */
#media (min-width: 800px) {
.small {
display: none;
}
.middle {
display: block;
}
.large {
display: none;
}
}
/* Styles for size 1200px and more */
#media (min-width: 1200px) {
.small {
display: none;
}
.middle {
display: none;
}
.large {
display: block;
}
}
I choosed 800px and 1200px as the breakpoints. You can modify them or add new ones.

Categories