HTML/CSS Mobile compatibility - html

A few days ago I started learning HTML / CSS in my spare time and programming my own test website. At some point I encountered a problem when I tried to visit my website on my smartphone. Here Here you can see that the Picture is shifted above the border.
Everything works fine on the desktop, but as you can see, it has moved on the mobile device. I tried several methods, but none of them resolved the problem. Since I just started, I have no other ideas.
I do not want to post all my code, so the problem is here
thank you in advance

Your problem is not only related to mobile I'm afraid.
That is what happens when you float, the container element loses its layout. To fix it you just need to give it back applying for example an overflow: hidden.
But I suppose you want to still have the img on the right of the Personal Data, for that you have to put the image inside the same container, applying the overflow: hidden.
Just like this:
/*SCHRIFTART*/
#font-face {
font-family: 'Levenim MT';
font-style: normal;
font-weight: normal;
src: local('Levenim MT'), url('ufonts.com_levenim-mt.woff') format('woff');
}
/*ALLGEMEIN*/
* {
margin: 0;
padding: 0;
}
/* CONTENT */
#PB-Bild {
float: right;
margin-top: 6px;
margin-right:7.5px;
}
#Information {
overflow:hidden;
height: 30%;
width: 98%;
border: 7px outset grey;
background-color:whitesmoke;
font-family: 'Arial Rounded MT';
padding-left: 5px;
color:darkblue;
}
.was {
font-size: 150%;
font-weight:900;
}
p.was::first-letter {
color:brown;
font-size:160%;
}
.was {
font-family:Arial;
color: black;
}
.uText {
font-family:Arial;
background-color:ivory;
font-size:120%;
}
<div id="Information">
<img id="PB-Bild" src="https://fakeimg.pl/300x350">
<p class="was">Name:</p>
Domenic Malz <br>
<p class="was">Alter:</p>
16 Jahre <br>
<p class="was">Geboren am:</p>
29.04.2002 <br>
<p class="was">Wohnort:</p>
Berlin <br>
<p class="was">E-Mail</p>
postfach#domenicmalz.de <br>
</div>

The issue you are bringing is known as responsiveness. There are many ways to make your website responsive, first thing I noticed when looking at your code, in your css you are making use of "px" values, they are pixel values meaning they are not scaling with the size of the screen. You should familiarise yourself with more responsive values such as "vw" and "vh" that do scale according to the size of the screen.

If you add a few properties to #banner2, you can ensure the background does not auto scale.
#banner2 {
…
background-size: cover;
background-position: center;
}

Related

The font-size could not be decreased using CSS

I'm using bootstrap and I'm trying to make a hint paragraph's p.tiny text very tiny in size. Using developer's tools show me that the font could not be smaller if it is less than 15 px. The following is what I have tried:
window.history.back();
nav,
.container {
display: none;
}
h1 {
color: red;
}
div.panel * {
text-align: center;
font-family: AraJozoor-Regular, Arial, Ubuntu, serif;
text-shadow: 1px 0px 2px #800000;
}
div.panel hr {
height: 20px;
background: red;
}
div.panel img {
display: block;
margin: 0 auto;
}
p.tiny {
font-size: 8px !important;
text-shadow: none;
font-style: italic;
font-weight: 400;
font-family: sans-serif;
}
<div class="panel">
<img src="/imgs/wrong.png" />
<h1>Error: 1</h1>
<h3>This Application Works Only With Javascript Enabled Browsers.</h3>
<h3>Please contact the system Administrator.</h3>
<div>Your browser: Chrome, Version: 61.0<sup>(*)</sup></div>
<hr />
</div>
<p class="tiny">(*): It`s estimated information and it may not be accurate enough.</p>
I also tried to set the font size of p.tiny with proportional units, i.e % and em but that would not decrease the font size either.
Some browsers have a "minimum font-size" setting (for example Firefox: 10px) and they won't display text smaller than that to keep it always readable. This is purely a browser setting and overrides any CSS rules. I f you change this setting to 8px, you'll see the desired result, but other users won't, unless they change that setting in their browser.
the code you provided in the question has the style and script tag between the </head> and <body> This is not legal. Try moving the tags?
here is a working version
plnkr.co/edit/FFB1K3j1dmUaWdBir5M9?p=preview

image as a logo by changing background color

I am trying to put this image as logo so it appears on the top of the page. I have tried to put background-color:transparent; but it's still not mixing well. I only want the text in the image to appear on the page. Can someone please help me? I know I am doing it in a really stupid way.
* {
margin: 0px;
padding:0px;
}
body {
background-color: black;
}
#logo {
background-color: transparent;
}
<img src="https://i.stack.imgur.com/3jXRQ.png" id="logo">
You could try to use the blend mode, but with this may affect the logo colors too, depending on the mode.
The structure is the following:
.blended {
background-image: url(url.jpg);
background-color: color;
background-blend-mode: mode;
}
There are several modes: : screen, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hue, saturation, color, and luminosity.
But the better idea is to change the logo itself in the graphics editor.
As pointed out in the comments, your image does not have a transparent background.
It has a white background. You need to edit your image to have a transparent background.
Alternatively, you could attempt to create your logo entirely with HTML/CSS.
Here is an example using just native system fonts. Using #import or #font-face, however, you could actually use the exact fonts that your logo (image) is using. Given the simplicity of the logo, you should be able to faithfully recreate it this way.
body {
background: #000;
}
#logo {
font-family: Arial, sans-serif;
font-size: 40pt;
font-weight: normal;
letter-spacing: -1px;
color: blue;
}
#logo em {
font-family: serif;
font-style: italic;
font-size: 58pt;
font-weight: bold;
color: green;
}
#logo span {
font-size: 48pt;
}
<h1 id="logo"><em>be</em><span>C</span>reative.com</h1>

Paragraph text not wrapping in Safari/iOS

I have a site with a small pricing blurb. In every browser I've tested in (Chrome, Firefox, IE, Safari for Windows, Chrome for Mac) it looks exactly as intended:
Unfortunately, though, in Safari for Mac, iOS Safari, and Chrome for iOS, the "MEMBERSHIP" text doesn't wrap to the next line and is pushed to the right farther than it should be:
Since I am not aware of any inspector for mobile, I'm having a really hard time figuring out why this text is displaying in the wrong place.
Here's the HTML:
<div id="home-cta-text">
<p style="font-size:40px; text-align:center; font-family:'Franchise-Bold', Arial, sans-serif; line-height:40px; color:#fff; margin-left:auto; margin-right:auto;">
MEMBERSHIPS AS LOW AS
</p>
<div id="home-cta-right" style="float:none; margin-left:auto; margin-right:auto;">
<p><span>$19</span><sup>.99</sup></p>
<p class="home-cta-subtext">PER MONTH</p>
</div>
<div style="clear:both;"></div>
</div>
And appropriate CSS:
#home-cta-text {
padding: 1em;
background-color: rgba(0, 0, 0, 0.4);
width: 377px;
margin-left: auto;
margin-right: auto;
max-width: 100%;
}
#home-cta-right {
float: left;
width: 156px;
}
#home-cta-left p, #home-cta-mid p, #home-cta-right p {
font-family: 'Franchise-Bold', Arial, sans-serif;
font-size: 109px;
color: #fff;
line-height: 90px;
padding-bottom: 0;
}
#home-cta-text p.home-cta-subtext {
font-size: 40px;
line-height: 40px;
}
#home-cta-text sup {
position: relative;
height: 0;
line-height: 1;
vertical-align: baseline;
font-size: 49px;
display: inline;
margin: 0;
padding: 0;
bottom: 43px;
}
Can anyone tell me what's going on here?
EDIT: I just noticed that if I remove my #font-face font, the text wraps normally. What's going on here?
I'm having the exact same problem on safari 10+ with the same font. Works perfectly on all other browsers. Looks like a problem with Franchise Bold. I'm going to try downloading it again, hoping there's something wrong in the font files.
EDIT: Apparently I got the wrong files in my assets. Downloaded the font again from Weathersbee Type (http://www.weathersbeetype.com/fonts/franchise/) and it now works in Safari 10+ (and all other browsers).
try use not 'P' just use DIV, and use just text-align center

odd text behavior in chrome/IE 11/ firefox

I am encountering a peculiar text behavior with different browsers. I cannot say which browser of the 3 is acting peculiar. Before I give out the details of my problem let me illustrate the issue I am encountering..
Outputs::
layout format::
Now the corresponding css codes are as follows::
#feature_links_inner_block {
width: 205px;
height: 390px;
margin: 0 auto;
}
#side_nav_links {
width: 99%;
height: 375px;
margin: 0 auto;
}
.one_third_side_nav_block {
width: 100%;
height: 125px;
}
.one_third_side_nav_block h4 {
margin: 3px 0px 0px;
padding: 0;
font-family: "marcellus sc";
font-size: 19px;
color: #f1d000;
text-align: center;
}
.one_third_side_nav_block img {
float: left;
margin: 1px 3px 0px 1px;
}
.one_third_side_nav_block p {
margin: 3px 0px 5px 0px;
font-family: "trebuchet ms",Arimo, sans-serif;
font-size: 14px;
color: #fff;
}
HTML::
<div id="feature_links_inner_block">
<div id="side_nav_links">
....
<a href="news_media_blurbs.html">
<div class="one_third_side_nav_block white_bottom_border">
<h4>News, Media & Blurbs</h4>
<img src="../Images/png/apply.png" alt="News and Media image" />
<p>What is happening now?</p>
</div>
</a>
...
</div>
</div>
I am trying to figure out what is causing this to happen. Its the same code but rendered different. I have tried to look at the computed values in each browser but they all seem to be the same. If anyone wants it i have the computed values of chrome and firefox copied as a text file.
Ideally I want the final output to look like the chrome output. This is just a small part of the page. I have other sections in the page which runs into similar issue.
Is chrome rendering correctly and the rest 2 not? or is it the other way around?
Any help is appreciated. Thanks in advance
Addendum::: I forgot to mention that I am using HTML5-Boilerplate as my template
The issue here was that the div containing the H4 element was not rendering with a large enough width in Chrome to display the H4 on a single line and the text was wrapping. The OP said that this was actually the desired effect, so I suggested manually adding in a line break to force the H4 to break at the desired point.
If the OP had wanted the H4 to remain on one line, they could have, alternatively, reduced the font-size by a point or two to allow the H4 enough room to exist on one line across all browsers.
This ended up working for the OP:
<h4>News, Media &<br/>Blurbs</h4>

how to cope with text to element alignment issues

My designer colleague obviously aligns his text nicely justified in his Photoshop.
How can I apply his design to my code when there will always be some space around text?
I mean I can fiddle with things like negative margin, line-height (see example) or anything. But that can't be a solution.
This question most likely arose already
An example: http://jsfiddle.net/bfpPS/
html:
<section>
<h1 class="wrong">WRONG</h1>
<img src="http://creativemedias.files.wordpress.com/2010/02/a_beautiful_day___wp_pack_by_little_stock.jpg" />
<h1 class="right">Isn't it beautiful!</h1>
</section>
css:
section, img, h1 {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
line-height: 1.4285714285714em;
vertical-align: baseline;
background: transparent;
font-family:'Lato', Arial, Arial, Helvetica, sans-serif;
font-weight: normal;
letter-spacing: 0;
}
img {
height: auto;
max-width: 100%;
width: 50%;
float: left;
}
h1 {
font-size: 2em;
}
.wrong {
float: left;
}
.right {
line-height: 0.7em;
}
We all know that "WRONG" is the right way to code this. Your designer is wrong here, not your CSS. Normally when I encounter situations like this, I ignore the exact design and do it how I know is the right way to do it, and then if anyone complains, I tell them that's how the web works. Even if you set a negative margin or do something else hacky, it's going to look wrong in someone's browser who has a different font available or a larger font size set, etc. Why bother with the hacks? Just do it right.