How to make the text smaller when minimising the browser CSS - html

I have came across a problem, whenever I make my browser smaller the text stays the same and it doesn't go smaller. How do I make the text go smaller when I the browser gets smaller?
Please visit http://jsfiddle.net/xiiJaMiiE/PjbHs/ for my website
.home {
font-family:apple;
position:relative;
font-size:25px;
color:black;
top:20%;
display:inline-block;
}
Thanks in advance!

As mention above you need to use media queries if you want to change your font-size (or any other CSS value based on browser / screen size)
Below is example based on Mobile Screen Size
// Work For All Other Screens Except the one which we redefine in bottom
.home {
font-family:apple;
position:relative;
font-size:25px;
color:black;
top:20%;
display:inline-block;
}
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
.home {
font-size:20px;
}
}
You only need to define value which you want to change browser rest all values form above style and only change font-size to 20px on screen size 320px
Keep in mind you need to include libraries like https://github.com/scottjehl/Respond in your page to support older browsers

This css should work for you... simply adjust/delete the query breaks as needed and adjust the font size as well.
.home {
font-family:apple;
position:relative;
font-size:25px;
color:black;
top:20%;
display:inline-block;
}
#media all and (min-width: 1281px){
.home{font-size:25px;}
}
#media all and (min-width: 1025px) and (max-width: 1280px) {
.home{font-size:22px;}
}
#media all and (min-width: 769px) and (max-width: 1024px) {
.home{font-size:18px;}
}
#media all and (min-width: 481px) and (max-width: 768px) {
.home{font-size:16px;}
}
#media all and (min-width: 321px) and (max-width: 480px) {
.home{font-size:14px;}
}
#media all and (max-width: 320px) {
.home{font-size:14px;}
}

I would highly recommend to not use px for font sizes, as each browser has a different standard font size to begin with. however there is an alternative which can give you the result you want across all browsers, old and new.
css:
#px {
font-size:25px; /*this was the size you want*/
}
#percent {
font-size:160%; /*this is what it is in % but give you the support for crossbrowser coding*/
}
incase you want to try it out here is the html to show you the difference
html:
<p id="px">HELLO</p>
<p id="percent">HELLO</p>

It's possible using viewport units but it does require a small amount of JS/JQ due to a minor bug.
http://css-tricks.com/viewport-sized-typography/
http://caniuse.com/viewport-units tells browser support
Codepen Demo
CSS
p {
font-size:1vw;
}
JQ
causeRepaintsOn = $("p"); /* could include any text related tags */
$(window).resize(function() { causeRepaintsOn.css("z-index", 1); });

Related

How to detect landscape mode and hide html content using css, queries or js

In my responsive website I want to control the way the website is viewed in mobile devices, and forbid viewing from landscape mode.
I searched through the stackoverflow site and found the option of putting a warning message.
I tried the css code below but it didn't work. Do you have any suggestions?
#media screen and (max-width: 980px) and (orientation:portrait){
#warning-message {
display:none;
}
}
#media screen and (max-width: 980px) and (orientation:landscape){
.content {
display:none;
}
.mobile {
display:none;
}
#warning-message {
display:block;
}
}
The ‘orientation’ media feature is ‘portrait’ when the value of the ‘height’ media feature is greater than or equal to the value of the ‘width’ media feature. Otherwise ‘orientation’ is ‘landscape’.
#media all and (orientation:portrait) { … }
#media all and (orientation:landscape) { … }
Source : https://www.w3.org/TR/css3-mediaqueries/#orientation

Issue automatically resizing main title text

I am updating a consultancy website that is hosted on Squarespace and I am having sizing issues with the title (it doesn't respond to browser size)
Here is the link to the webpage
If you resize the page you will see the word eCommerce doesn't resize to fit the screen.
I have tried adding in some custom css but its not working well
#media screen
and (min-device-width: 751px)
and (max-device-width: 1110px)
{
#introduction .sqs-block-content h1{
font-size:100px;
}
}
#media screen
and (max-device-width: 750px)
{
#introduction .sqs-block-content h1{
font-size:100px;
}
}
I have since removed the code form the website.
Do you guys have any idea how I can get the main text to resize based on the size of the browser using CSS?
I think you were on the right path, but for some reason decided to use *-device-width instead of just *-width. I'm pretty sure device-width refers to the entire screen size, whereas width will refer to just the browser viewport size. Try this:
#media screen and (min-width: 751px) and (max-width: 1110px)
{
#introduction .sqs-block-content h1{ font-size:100px; }
}
#media screen and (max-width: 750px)
{
#introduction .sqs-block-content h1{ font-size:100px; }
}
For someone, who still has same question, i would recommend to use fittext plugin.
Non-jQuery standalone version also exists
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.fittext.js"></script>
<script>
jQuery("#responsive_headline").fitText();
</script>

media seems to not calculate the screen size properly

I'm trying to make a responsive index for my website, for this, i'm using Firefox Responsive Design Mode. In 1920x900px, my #media is working perfectly. The problem is when i change to 1280x600px. He keeps getting the images positioning like i order in 1920x900px. I made some tests and other attributes for 1280x600px works ! Here's the comments in my code:
/* Para monitores 1280x600px */
#media screen and (max-height:600px){
#slider{
/* If i change this to display:none; it really disappear the tag,
which makes me guess the screen calc is doing ok.*/
height:73.5vh;
}
}
#media screen and (max-width:1280px){
#mainAtc{
margin-left:2vw;
}
#othAtc{
margin-left:0;
}
}
/* Para monitores 1920x900px */
#media screen and (max-height: 900px){
#slider{
/* But, if in 1280x600 i got display:none, and here i got display:block, he shows me the image. It's like it doesn't work just when i give same attributes to differente #media. */
height:51.6vh;
}
}
#media screen and (max-width: 1920px){
#mainAtc{
margin-left:2vw;
}
#othAtc{
margin-left:7.6vw;
}
#atcRest{
margin-left:2vw;
}
}
Someone could help me ? Thanks!

Media Queries not working at all whatsoever

I am in despair. I am trying to make a website and make it mobile-friendly and responsive, however, I cannot seem to get any kind of media query to work at all! All my sizes, width and heights are in "%/em" and my font-sizes are in "vw/em". The biggest problem I get is that, as the screen shrinks, so does my text, to the point where it simply becomes eye-straining to read! I don't see relevant to send any code but if need be, I shall send some of my code (my website is still offline and I cannot put it out there if this problem isn't fixed).
Here's what I have tried:
I have tried putting this in my tag:
<meta name="viewport" content="width=device-width, initial-scale=1">
No success when I try media query in a tab or in a separate css stylesheet.
I have tried removing it aswell.
I have tried these media queries for my font-sizes:
#media (max-width: 400px) {
body { font-size: 60%;}
}
#media only screen and (max-device-width: 800px) {
body {
font-size: 80%;
background-color: blue;
}
}
#media (max-width: 1100px) {
body { font-size: 120%;}
}
I have also tried other media queries but absolutely NOTHING changes at all! Am I doing something wrong? Probably but what?!! This is leading to so many problems! I cannot change my header according to different screen sizes, I cannot change my display, my header links are a mess, etc.
Also, please note that I am a beginner and I do not use any javascript, bootstrap or whatever.
Thank you in advance for your help!
Your queries are a little weird. Perhaps with some logical constrains you can achieve what you are looking for? This is what I mean:
#media (max-width: 400px) {
body{
background-color: yellow;
}
}
#media (min-width: 401px) and (max-width: 800px){
body {
background-color: blue;
}
}
#media (min-width: 801px) and (max-width: 1100px) {
body {
background-color: purple;
}
}
#media (min-width: 1101px){
body{
background-color: orange;
}
}
In my humble opinion, setting the intervals using both min-width and max-width help me visualize what's going on better. This pen shows the colors changing whenever you change the width. It doesn't do much good, but it's something to get started with media queries.
EDIT:
Pen contains transitions between colors because cool
Usually, it's better to use media queries based on minimum screen width. Here is an working example with the code you posted:
Codepen: http://codepen.io/anon/pen/eNJXXp
#media (max-width: 400px) {
p { font-size: 60%;}
}
#media (min-width: 400px) {
p {
font-size: 80%;
background-color: blue;
}
}
#media (min-width: 800px) {
p { font-size: 120%;}
}

How to make Bootstrap look more "Compact"

I want to have the same "Compact" look - in terms of font-size, padding and general use of space as I get when I use the browser zoom-out (Ctrl--). Of course without the side-effects most importantly reduction in container width.
I have tried fiddling with the #baseFontSize and #baseLineHeight variables in Bootstrap's http://getbootstrap.com/2.3.2/customize.html download screen but I am missing something as the result :
Doesn't look right - in terms of balance, padding is not right.
Breaks on the projector screen (the horror!) - select boxes, layout, everything goes crazy.
Please bail me out!
What about using media queries inside your html tag and using rem units based off it? Might be too late to start that but I find it a hand way to control spacing,
html{
background: $black;
scroll-behavior: smooth;
padding:0;
margin:0;
#media screen and (min-width: 2560px){
font-size:16px;
}
#media screen and (min-width: 1920px) and (max-width: 2559px){
font-size:15px;
}
#media screen and (min-width: 1681px) and (max-width: 1919px){
font-size:15px;
}
#media screen and (min-width: 1441px) and (max-width: 1680px){
font-size:13px;
}
#media screen and (min-width: 1366px) and (max-width: 1440px){
font-size:13px;
}
#media screen and (min-width: 1024px) and (max-width: 1365px){
font-size:12px;
}
#media screen and (min-width:992px) and (max-width: 1023px) {
font-size:12px;
}
#media screen and (min-width:768px) and (max-width: 991px) {
font-size:12px;
}
#media screen and (min-width:441px) and (max-width:767px) {
font-size:12px;
}
#media screen and (min-width:351px) and (max-width:440px) {
font-size:12px;
}
#media screen and (max-width:350px) {
font-size:12px;
}
I am wondering if this is a problem related to the responsive style sheet. It is hard to give a definitive answer without knowing if you are working with or without the responsive style sheet. But if you are, the layout will not stay in proportion to a larger screen because it is responsive. So, if you do have that style sheet on, try removing it.
Bootstrap Table Compact
table-sm
To reduce the cell padding on your tables add a class .table-sm to your Bootstrap table.
Example below
<table class="table table-sm">
I have two suggestions.
First, are you using Bootstrap 2.3.2 per your link above? You may be able to more easily solve your problems by using the new scaffolding that boostrap 3.0 (and up) has. It is kinda a pain to upgrade your site, but there are automatic converters, and the new system is MUCH better to work with, and might help.
Second, another CSS trick you should look into is font-weight and line-height. Font-weight can make your text thinner/thicker (grades are 100, 200, 300, 400, etc...). You might be able to make the font thinner, the lineheight lower, but the overall font bigger, which would "compact" things. If you didn't know it's worth trying.
font-weight: 200;
line-height: 30px;