How to resize texts in all devices? - html

I want to make text to be resize in all devices. It looks good when I view in on my PC but when I view it on my phone, it doesn't fit to the box and overlap with the button above and below
Here is my code
.container-profile {
position: relative;
width: 100%;
}
.image {
display: block;
max-width: 100%;
height: auto;
}
.overlay-profile {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.container-profile :hover .overlay-profile {
opacity: 1;
}
.text {
color: white;
font-size: auto;
position: inherit;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-transform: translate(-50%, -50%);
}
<div class="wrapper bgded; container-profile">
<div class="container-profile">
<img src="https://www.kent.ac.uk/sportsciences/employability/images/image-pending.png" alt="Avatar" class="image">
<div class="overlay-profile">
<div class="text">
<p class="text-justify">SCORE (Standing Commitee on Research Exchange) merupakan Organisasi berbentuk Badan Semi Otonom, bersifat Independent dan berstatus sebagai satu-satunya organisasi penelitian mahasiswa Fakultas Kedoktean Universitas Sumatera Utara yang bergerak
di bidang penelitian dan kelimiahan. Berdiri pada tanggal 19 Agustus 2003 dan berkedudukan di Medan, Kampus FK USU. Semenjak berdiri, SCORE bertujuan untuk mewujudkan dan menumbuhkan budaya ilmiah di lingkungan Kampus Fakultas Kedoktean Universitas
Sumatera Utara. SCORE tergabung dalam Badan Analisis dan Pengembangan Ilmiah Nasional Ikatan Senat Mahasiswa Kedokteran Indonesia (BAPIN ISMKI).</p>
<br>
<p style="font-style: italic; text-align: center;">Scripta Manent Verba Volent <br> "Yang tertulis akan abadi, dan yang terkatakan akan binasa"</p>
</div>
</div>
</div>
</div>
Click here for example

Just need to add a metadata in your HTML file like
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, target-densitydpi=device-dpi" />
This will adjust your font size in device.

You can use the media queries to get the different sizes fonts to suit the device you are using.
more about media queries

Set .logoHeader div height auto.
.logoHeader{
height: auto;
min-height: 120px;
}
If That's not the problem. you can check Nitheesh's and Al Amin's answer.

just spend some time to play with Viewport-percentage
viewport-percentage values are:
vw (the viewport width)
vh (the viewport height)
vi (1% of the viewport size in the direction of the root element's inline axis)
vb (1% of the viewport size in the direction of the root element's block axis)
vmin (the smaller of vw or vh)
vmax (the larger or vw or vh)
hope your problem will be solve if you use vw like this:
.text {
font-size: 5vw; // OR whatever value you need
}

Related

How to make my website not become distorted when I zoom in and out?

I am currently working on a website and I was wondering how I can make my website not to distort when I zoom in a and out. Zooming at 150% makes all the navigation buttons get all clustered up causing them to overlap each other. I tried using media tags which proved to work well with other devices, however, it does not seem to work when zooming in and out. (NOTE: This is my first ever website so you cna understand my confusion). Here is my code:
HTML & CSS:
*{
margin: auto;
padding: auto;
box - sizing: border - box;
font - family: Century Gothic;
}
header {
height: 15 % ;
background - size: cover;
background - position: center;
background - color: #ebebeb;
border - bottom: 5 px solid# A9A9A9;
}
#media(min - width: 768 px) and(max - width: 991 px) {
header {
height: 8 % ;
}
}
#media(min - width: 768 px) and(max - width: 1199 px) {
header {
height: 13.5 % ;
}
}
#media(min - width: 960 px) and(max - width: 1400 px) {
header {
height: 11.5 % ;
}
}
html,
body {
/* background: #000000;*/
font - size: .80e m;
/* font-family: "Balsmiq", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;*/
margin: 0 % ;
padding: 0 % ;
color: #696969;
height: 100%;
width: 100%;
}
/*Carousel*/
.carousel-container {
width: 70%;
max-height: 800px;
margin: auto;
margin-top: 1%;
overflow: hidden;
border: 5px solid white;
}
.carousel-slide {
display: flex;
width: 100%;
height: 400px;
}
# prevBtn {
position: absolute;
top: 40 % ;
z - index: 10;
left: 20 % ;
font - size: 50 px;
color: white;
opacity: 0.5;
cursor: pointer;
}
#
prevBtn: hover {
color: black;
}
#
nextBtn {
position: absolute;
top: 40 % ;
z - index: 10;
right: 20 % ;
font - size: 50 px;
color: white;
opacity: 0.5;
cursor: pointer;
}
#
nextBtn: hover {
color: black;
}
<header>
<div class="main">
<div class="logo-text">
<h1 class="text-logo">TITLE</h1>
</div>
<div class="menu-container">
<nav>
<ul>
<li>Home</li>
<li>Store</li>
<li>About</li>
<li>Contact Us</li>
</ul>
</nav>
</div>
</div>
</header>
<div class="page-wrapper">
<!--Image Slider-->
<div class="back-color">
<div class="carousel-container">
<i class="fa fa-angle-left" id="prevBtn"></i>
<i class="fa fa-angle-right" id="nextBtn"></i>
<div class="carousel-slide">
<img src="./img/testpic3.jpg" id="lastClone" alt="Could not load">
<img src="./img/testpic1.jpg" id="first" alt="Could not load">
<img src="./img/testpic2.jpg" alt="Could not load">
<img src="./img/testpic3.jpg" id="last" alt="Could not load">
<img src="./img/testpic1.jpg" id="firstClone" alt="Could not load">
</div>
</div>
</div>
There reason I included the Image slider is because it distorts aswell. When I zoom out you are able to view the other pictures which I have hidden.
Any help would be helpful. Thanks in advance!
What I think is the problem with that zooming, is, that you have specified the dimensions in percentage because of what your elements change themselves according to undefined dimensions. If you will use px or vw problem will be resolved... VW and VH are also percentages but they haves a ratio with the view port's dimensions, which prevent them from distorting their shapes on zoom. That's my take on it!
% are relative to parent elements,
whereas, vw and vh are relative to view port.
Check this link for more info

How to make text block on image responsive?

I have created a text block on an image but when I check the site on iPad and iPhone the image stays ok, but the text moves.
How can I make this text responsive?
Link: http://test.preci-dental.be/home/
This is the code I used:
<style>
.container {
position: relative;
font-family: Arial;
}
.text-block {
position: absolute;
bottom: 20px;
left: 95px;
right: 740px;
background-color: white;
opacity: 0.75;
color: black;
padding-left: 20px;
padding-right: 20px;
}
</style>
</head>
<body>
<div class="container">
<center><img src="http://test.preci-dental.be/wp-content/uploads/2019/01/helping-your-child-trust-the-dentist-1110x450-1024x415.jpg" alt="Nature" style="width:90%;"></center>
<div class="text-block">
<h1 style="color:#749C91;">Preci-Dental</h1>
<br><p style="color:black;">Welkom bij tandartspraktijk Preci-Dental. De groepspraktijk werd door Liesbeth en Karel opgericht in 2019 en is gevestigd in Bertem, gelegen tussen Leuven en Brussel. Bij Preci-Dental streven we naar moderne mondzorg op maat voor iedereen: precieze en persoonlijke service, gebaseerd op bewezen efficiënte en moderne technieken.</strong></p>
</div>
</div>
Thank you in advance!
If you don't mind on using media queries, i guess this should solve your problem:
PS: I used "!important" because i injected the code via plugin. Maybe is not needed in your case.
I'm also assuming you want the text area as 70% of your viewport width and 600px as max-width in your media query. So, when your viewport width is smaller than 600px, the code will override your css for this selector.
About media queries: https://www.w3schools.com/css/css_rwd_mediaqueries.asp
#media only screen and (max-width: 600px) {
.text-block {
left: auto !important;
right:auto !important;
min-width:70vw;
}
}

Relative positioning to an absolutely positioned element

I am experimenting with single-page design, and have built a page out of a number of different pages, by essentially creating a column of <div> elements each at 100% of the window height, and positioned absolutely one under another.
Each page, therefore, requires it's elements to be set absolutely, since there is (as far as I can tell) no normal document flow to follow. However, when it comes to text, I am finding it difficult to design. I'd like to try and keep the current design, rather than start over.
On a particular page, I have a text container. In that container, there are two titles. The first title heads two small paragraphs, the second heads one:
HTML
<div id="introTextContainer">
<div id="introTextHeader" class="blurbheader">First title</div>
<div id="introText" class="blurb">
Generic text about the roots of the company
</div>
<div id="introTextParg2" class="blurb">
further information about the roots
</div>
<div id="introStatement1" class="blurb StrongStatement">
Second title
</div>
<div id="introTextParg3" class="blurb">
Eye-catching mission statement
</div>
</div>
CSS
.blurb {
font-family: Lato;
font-size: 16px;
padding-right:10px;
font-size: 1.4vh
}
.blurbheader {
font-family: Lato;
font-size: 2vh;
padding-right:10px;
}
.StrongStatement {
font-family: Lato;
font-size: 20px;
}
#introTextContainer {
height: 20%;
width: 45%;
background: rgba(255,255,255,0.8);
position: absolute;
left: 200px;
top: 10%;
border-radius: 5px;
}
#introTextHeader {
position: absolute;
width: 280px;
left: 30px;
top: 5px;
height: 10%;
}
#introText {
position:absolute;
left: 10px;
font-family: Lato;
}
#introTextParg2 {
position:absolute;
left: 10px;
}
#introStatement1 {
position:absolute;
left: 30px;
}
#introTextParg3 {
position:absolute;
left: 10px;
}
At a standard resolution of 1080p, all of this looks perfectly acceptable. However, when the resolution is changed, the design is not responsive to the same. As you can see with the CSS, I have been experimenting with viewport-height for the text, however the spacing and height of the <div> elements is a different matter.
How can I create a positioning/size context within the scope of the text containers, in order that I can set the height and padding of the text paragraphs therein, within the scope of those containers? The current approach uses javascript, but I don't like the idea of attempting to use javascript to target every screen size possible as this would result in a lot of spaghetti code. Ideally, I would like to use javascript only to set the heights of the "page" <div> elements and the containing boxes.
edit: CSS, JS, HTML of page design
The first page is given a width and height of 100%. The subsequent pages are altered with JQuery. The value data-section-name is used in the seamless scrolling plugin. The canvas is used only to house the background image:
HTML
<section id="pageOne" class="panel pageone" data-section-name="sectionpageOne"> <!-- About -->
<canvas id="pageOneCanvas"></canvas>
<div id="introTextContainer">
<div id="introTextHeader" class="blurbheader">First title</div>
<div id="introText" class="blurb">
Generic text about the roots of the company
</div>
<div id="introTextParg2" class="blurb">
further information about the roots
</div>
<div id="introStatement1" class="blurb StrongStatement">
Second title
</div>
<div id="introTextParg3" class="blurb">
Eye-catching mission statement
</div>
</div>
</div>
</section>
CSS
#pageOne {
position: absolute;
/*top: 0;*/
left: 0;
width: 100%;
}
#pageOneCanvas {
height: 100%;
width: 100%;
z-index: 1;
background-image: url("/Resources/images/aboutcanvas.jpg");
background-size: cover;
opacity: 0.6
}
JS
// Canvas height and positioning
var posheight = $(window).height();
$("#home").height(posheight);
$("#pageOne").height(posheight);
$("#pageTwo").height(posheight);
$("#pageThree").height(posheight);
$("#pageFour").height(posheight);
$("#pageFive").height(posheight);
$("#pageOne").css("top", posheight);
$("#pageTwo").css("top", (posheight * 2));
$("#pageThree").css("top", (posheight * 3));
$("#pageFour").css("top", (posheight * 4));
$("#pageFive").css("top", (posheight * 5));
Additionally, the current solution for fixing the text container dimensions is also in JS. You can start to see why I want to achieve this in CSS, as it's becoming messy here:
var introTextTitleHeight = $("#introTextHeader").height();
$("#introText").css("top", (introTextTitleHeight + 10));
$("#introTextParg2").css("top", ($("#introText").position().top + $("#introText").height() + 10));
$("#introStatement1").css("top", ($("#introTextParg2").position().top + $("#introTextParg2").height() + 10));
$("#introTextParg3").css("top", ($("#introStatement1").position().top + $("#introStatement1").height() + 10));
Would removing position: absolute; on the child divs not do what you want?
And use margin-left instead of left.
So the rules would look like this:
#introTextHeader {
margin-left: 30px;
margin-top: 5px;
height: 10%;
}
#introText {
margin-left: 10px;
font-family: Lato;
}
#introTextParg2 {
margin-left: 10px;
}
#introStatement1 {
margin-left: 30px;
}
#introTextParg3 {
margin-left: 10px;
}

width doesn't change in css

hello I have made a pop up effect in css it is a div that contains two floating divs the first one width is 34.8% of the main pop up and the second one is 65%
now I want to change the design of the whole pop up once the screen get smaller so I used a media query to change the width and rearrange the elements ;however it won't change I think its because of the float thing here is the code please help
<div class="overlay"></div>
<div class="popup">
<div id="itemphoto">
<img src="../images/stuff%20for%20sale/1.jpg" alt="none">
<p id="itemtitle">IPhone 6s</p>
</div>
<div id="itemdesc">
<p><span>Seller :</span> 116825349</p>
<p><span>Seller Rate :</span> Trusted</p>
<p><span>Lower Bid : </span>250</p>
<p><span>Bidders :</span> 30</p>
<p><span>Higher Bid : </span>366</p>
<p><span>Brief Description :</span> SAN FRANCISCO — September 9, 2015 — Apple® today announced iPhone® 6s and iPhone 6s Plus, the most advanced iPhones ever, adding a powerful new dimension to iPhone’s revolutionary Multi-Touch™ interface. The new iPhones introduce 3D Touch, which senses force to enable intuitive new ways to access features and interact with content. iPhone 6s and iPhone 6s Plus feature Retina® HD displays made from the strongest glass on any smartphone and 7000 series aluminum, the same alloy used in the aerospace industry, in gorgeous metallic finishes that now include rose gold.</p>
</div>
<button id="bid">BID</button>
<button id="notify">NOTIFY ME</button>
<button id="close">CLOSE</button>
</div>
.popup
{
width: 70%;
height: 550px;
background: #292929;
z-index: 1001;
position: fixed;
top :10%;
left: 15%;
border-radius: 15px;
/* display: none; */
}
.popup #itemphoto
{
width: 34.8%;
margin-right: 0.2%;
height: 450px;
float: left;
border-top-left-radius: 15px;
overflow: hidden;
background: #EFF1F2;
}
.popup #itemdesc
{
width: 65%;
height: 450px;
float: left;
border-top-right-radius: 15px;
padding: 20px;
overflow-y: scroll;
background: #EFF1F2;
}
/*media queries*/
#media screen and (max-width:1000px)
{
.popup
{
width:80%;
left: 10%;
}
#itemphoto
{
float: none;
width: 100%;
}
}
change your media query to:
.popup #itemphoto {
float: none;
width: 100%;
}
As it's more specific than #itemphoto, it's keeping the properties of the main css, changing it to this will make it apply correctly.
https://jsfiddle.net/h5wbjcsq/

Can't click on my links after placing some images

I'm new in html and css so i have a question.
I am messing around with some stuff but after placing some images on my page i can't click on my links anymore.
HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/style.css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<title>Rijschool Houben</title>
</head>
<body>
<div id="header"></div>
<div id="header-pic"><img src="image/test.png"></div>
<p>
<div id="nav-bar">
<ul>
<li>|Home|</li>
<li>Info|</li>
<li>Prijzen|</li>
<li>Acties|</li>
<li>Machtiging|</li>
<li>Theorie|</li>
<li>Begeleid rijden|</li>
<li>Bromfiets|</li>
<li>Contact|</li>
</ul>
</div>
</p>
<p>
<div id="icon-main">
<i class="fa fa-mobile" style="font-size:28px;"></i><a>046-4524501</a><br />
<i class="fa fa-paste" style="font-size:18px;"></i><a>raymond#rijschoolhouben.nl</a><br />
<i class="fa fa-facebook-official" style="font-size:20px;"></i><a>Volg ons op Facebook!</a>
</div>
</p>
<p>
<div id="img-1">
<img src="image/1.jpg" alt="Scooter" width="330px" height="400px"/>
</div>
<div id="img-2">
<img src="image/2.jpg" alt="Geslaagde 1" width="337px" height="400px"/>
</div>
<div id="img-3">
<img src="image/3.jpg" alt="Geslaagde 2" width="337px" height="400px"/>
</div>
<div id="img-4">
<img src="image/4.jpg" alt="Geslaagde 3" width="337px" height="400px" />
</div>
<div id="img-5">
<img src="image/5.jpg" alt="Geslaagde 4" width="337px" height="400px" />
</div>
<div id="img-6">
<img src="image/6.jpg" alt="Geslaagde 5" width="337px" height="400px" />
</div>
</p>
</body>
</html>
CSS:
div#header{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100px;
background-color: white;
}
div#header-pic{
position: fixed;
height: 50px;
left: 500px;
}
div#nav-bar{
position: fixed;
padding-top: 130px;
left: 0;
width: 100%;
white-space: nowrap;
}
div#nav-bar ul{
list-style: none;
text-align: center;
background-color: #323232;
padding: 10px 0;
}
div#nav-bar li{
display: inline;
}
div#nav-bar li a{
text-decoration: none;
color: white;
padding: 14px 16px;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
div#icon-main{
position: fixed;
color: #323232;
padding: 10px;
}
div#icon-main i{
padding: 5px;
}
div#icon-main a{
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
div#img-1 {
position: fixed;
left: 0;
padding-top: 184px;
width: 100%;
}
div#img-2 {
position: fixed;
padding-top: 184px;
padding-left: 255px;
}
div#img-3 {
position: fixed;
padding-top: 184px;
padding-left: 915px;
}
div#img-4 {
position: fixed;
padding-top: 184px;
padding-left: 585px;
}
div#img-5{
position: fixed;
padding-top: 184px;
padding-left: 1245px;
}
div#img-6 {
position: fixed;
padding-top: 184px;
padding-left: 1575px;
}
i know the code is bad but i hope someone can help me!
Here is a fiddle.
-Ryan
I looked at your external code. Please add your HTML and CSS to your question in Stack Overflow.
From the external HTML you have the following code:
<a>046-4524501</a>
Which does not work as a link.
You have this code
Home
That works as you would expect it to.
Change this line:
<a>046-4524501</a>
to
046-4524501
Where the href="Where you want the link to go".
It's all about the value for "href"
I did notice you are doing non-responsive html which means it is not mobile friendly or will look the same in smaller browser windows.
Your code is messy but your doing okay.
First off wrap everything you are putting in the header in the header div
The images are floating up to the top over your nav due to the position:fixed
Remove all the empty <p></p> between your div's
Use floats on your images and width of a percentage of 100% plus wrap them in a container/div
If you need me to I can see if I can redo all your html and CSS but think for you would learn better to try it out for yourself.
You could always go look at the HTML5 boilerplate out there and use them to guide you on how to construct good code.
I see that you are trying to create a row of images. Instead of using a system of DIVs why don't you use the more flexible (and more responsive) structure of a list?
Then you can use float: for lining them up in a row and basic CSS to give them sizes. The images will be specified as a background for these li elements (better practice).
Like this: http://codepen.io/Attrexx/pen/KVvwXP
You are placing divs containing the images using padding. That's why you can not use links in the menu. Div blocks cover your links.
Try using something like:
selector {
position: absolute; /* or `fixed` like in your css; see below*/
top: 100px; /* pixels from the top */
left: 100px; /* pixels from the left */
/* you can also use `bottom` and `right` */
}
For example:
div#img-3 { /* or just `#img-3`; see below */
position: absolute;
top: 184px;
left: 915px;
}
Check this w3 schools article for more information on positioning.
Not related to the question:
If you are using CSS's id selector (#), I suggest not to use element selector (e.g. div). So rather than div#img-3 try using just #img-3.
Try avoiding using id selectors at all. You can use class rules, and happily after some time they will result in saving you a lot of work.
If you are using HTML5 then try using semantic elements.
Avoid using fixed position when you don't need to (your page is an example of such page).
Paragraphs (p) shouldn't be used in the same way as div. It may result in bad habit for semantic sites.
Rather than using positioning (position), experiment with float or different display types (e.g. inline-block). Use it only when it is really needed.
Read about HTML Responsive Web.