How to make text size responsive inside of a div? - wordpress

I'm trying to make a responsive wordpress theme and I am having trouble with the title text not being responsive.
When I try different screen sizes the title text eventually goes OUT of the header and I don't want that. I would like for it to stay inside the header div no matter the screen size.
My header:
<div id="header">
<div id="titlebox">
<p class="blogtitle"><?php echo get_bloginfo ( 'name' ); ?></p>
<p class="tagline"><?php echo get_bloginfo ( 'description' ); ?></p>
</div>
<div id="searchbox"><?php get_search_form(); ?> </div>
</div>
The CSS:
#header {
width: 100%;
height: 23.2%;
margin-top: 2.1%;
margin-bottom: 2.1%;
}
#titlebox {
width: 60%;
float: left;
}
.blogtitle {
font-style: normal;
text-shadow: 2px 2px #a2a2a2;
font-size: 3em;
padding-top: 2.1%;
padding-right: 2.1%;
padding-bottom: 0;
padding-left: 2.1%;
}
.tagline {
font-style: italic;
text-shadow: 1px 1px #a2a2a2;
font-size: 0.75em;
padding-top: 0;
padding-right: 2.1%;
padding-bottom: 2.1%;
padding-left: 2.1%;
}
#searchbox {
width: 40%;
float: right;
}

At smaller widths, your text is just too large so it overflows. You need to use media queries so that when your widths go below a certain point, you shrink the font size.
e.g.:
#media all and (max-width: 767px) {
.blogtitle {
font-size: 2em;
}
}
#media all and (max-width: 500px) {
.blogtitle {
font-size: 1em;
}
}
And to answer to last question, creative responsive design is way more than I can answer here. Rather than randomly picking breakpoints at which to change font sizes, use something like the Chrome Responsive Inspector plugin. It will show you what responsive breakpoints are already in use in your theme. It would be best to try and match those. That way your changes will match with any other changes in the theme at the same breakpoints.
That says that for all widths up to 767 wide, make the font-size for the .blogtitle class 2em instead of the default 3em.

This works for me
.resposive_text {
font-size: 30px;
font-weight: 600;
/*here put anything you want for desktop size*/
}
#media (max-width: 500px) {
.resposive_text {
font-size: 18px;
/*here put anything you want for mobile size*/
}
}
And in my div
<div class="resposive_text">
<p>Bienvenidos a ENL Team Peru</p>
</div>
HTH

Related

WordPress Elementor Responsive Media Queries

I have certain elements in CSS for which I use media queries to represent screen sizes.
When shifting the size of the browser on desktop, the queries do what they are supposed to do.
When working with the buttons for Mobile, Tablet and Desktop in Elementor as well as WordPress Customize, these do not react. They do not seem to measure tablet mode by max-width/ min-width. What is wrong with my code, how are these "modes" built up?
Main question is "which properties does WordPress/ Elementor use to determine which mode you are in?"
/* design elements with breakpoints - default for desktop */
/* elements included - top menu */
/* markup for desktop */
.top_menu_list{
list-style-type: none;
float: right;
margin-right: 40px;
}
li{
float: left;
}
.top_menu_list a{
display: block;
padding: 40px 20px;
font-size: 25px;
font-weight: bold;
}
/* markup for tablets */
#media screen and (min-width:769px) and (max-width:1024px) {
.top_menu_list{
list-style-type: none;
float: right;
margin-right: 40px;
}
li{
float: left;
}
.top_menu_list a{
display: block;
padding: 40px 20px;
font-size: 20px;
font-weight: bold;
}
}
/* markup for mobile */
#media screen and (max-width:768px) {
.top_menu_list{
list-style-type: none;
float: right;
margin-right: 25px;
}
li{
float: left;
}
.top_menu_list a{
display: block;
padding: 40px 8px;
font-size: 12px;
font-weight: bold;
}
}
I found an answer on this page..
https://github.com/elementor/elementor/issues/78
As from the last version (0.8) we're using these two primary breakpoints:
A. 768px and below for mobile.
B. 1024px and below for tablet.
I think that it covers the most devices. We prefer to keep it more simple for most users.
For more customization you can always use custom CSS.

Line height is not working in mobile for my portfolio site

New to stack overflow, but I was struggling on this one. I recently created my portfolio site which appears to be working across all device break points and the media query on my laptop in Chrome. However, when I go to the site on my phone (tried both Chrome and Firefox) the header line-height disappears. It's crunched and unreadable. Any ideas what might be happening there? I'd really appreciate it! It seems impossible to debug because it's only happening via mobile.
.text--header {
font-size: 30px;
line-height: 38px;
display: block;
font-stretch: none;
margin-top: 95px;
}
#media screen and (min-width: 320px) and (max-width: 630px) {
.text--header {
font-size: 30px;
letter-spacing: -0.04em;
line-height: 32px;
}
}
<div class="ct ct--body">
<span class="text text--header">Jenna is a Product/Visual Designer.</span>
</div>
Actually, the problem in Media query won't forget to follow standard declarations of the media query.
.text--header {
font-size: 30px;
line-height: 38px;
display: block;
font-stretch: none;
margin-top: 95px;
background-color: #ccc;
}
#media only screen and (min-device-width: 320px) and (max-device-width: 630px) {
.text--header {
font-size: 30px;
letter-spacing: -0.04em;
line-height: 32px;
background-color: red;
}
}
<meta name="viewport" content="width=device-width" />
<body>
<div class="ct ct--body">
<span class="text text--header">Jenna is a Product/Visual Designer.</span>
</div>
</body>
Appreciate if it is useful :)

Compiling Bootstrap in LESS - How can I have a different navbar height for mobile?

My entire AngularJS website is reponsive. It is responsive to the screen size & loads the same pages for mobile, desktop, and tablet. However, I am having trouble getting the navbar to be a separate height on different devices in a responsive way.
Mostly, I just want the navbar to load at a slimmer height on mobile so that more of the screen space can be utilized for actual content that the user wants to see.
Right now, I am setting the height variable in variables.less which is where I know how to alter navbar height settings currently.
Variables.less
// Basics of a navbar
#navbar-height: 64px; // most relevant line!
#navbar-margin-bottom: #line-height-computed;
#navbar-border-radius: #border-radius-base;
#navbar-padding-horizontal: floor((#grid-gutter-width / 2));
#navbar-padding-vertical: ((#navbar-height - #line-height-computed) / 2);
#navbar-collapse-max-height: 340px;
#navbar-default-color: #gray-light;
#navbar-default-bg: #fff;
#navbar-default-border: transparent;
OK, so that is great, but I want 64px height to be set for desktop/tablet but 38px height to be set for navbar height on mobile screens.
I have already tried over-riding the navbar height in my local CSS with a media query but even with the !important flag it is not working to set the navbar to another height.
App.less <-- this doesn't work :(
#media (max-width: 767px) {
.navbar {
height: 35px !important;
}
.navbar-collapse ul li a {
line-height: 35px;
height: 35px;
padding-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
vertical-align: middle;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
.navbar-brand li a {
line-height: 35px;
height: 35px;
padding-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
vertical-align: middle;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
}
NOTE I am using Bootstrap 3. Also, if it makes any difference, Bootstrap is imported in the main app.less file like so: #import "bower_components/bootstrap/less/bootstrap.less";
What should I do? How can this be done in a responsive fashion?
(A.K.A. without making an entirely different site for mobile)
Thanks for all the help!
Based on comment above, I suggest you set min-height to 35px in your media query
.navbar {
min-height: 35px;
}
I think what prevents you to set the height is the min-height property set to the element with class navbar.
Adding min-height: 35px would be enough:
#media (max-width: 767px) {
.navbar {
height: 35px;
min-height: 35px;
}
...
Try the following syntax:
#media only screen and (max-width: 767px) {
.navbar {
height: 35px !important;
}
.navbar-collapse ul li a {
line-height: 35px;
height: 35px;
padding-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
vertical-align: middle;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
.navbar-brand li a {
line-height: 35px;
height: 35px;
padding-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 0px;
vertical-align: middle;
font-family: 'Open Sans', sans-serif;
font-weight: 700;
}
}

Can't make media queries work

I'm building a responsive wordpress theme and trying to set up size changing font, depending on screen width. Somebody suggested jquery, but i also decided to try css media queries. Font size still doesn't change and entire text slides under header background.
Live link here
http://soloveich.com/pr4/
Code looks like this
<div class="container-full" id="spbg">
<div class="row">
<div class="col-lg-5"><div class="visible-md visible-lg" id="gr"></div>
<div class="visible-sm visible-xs" id="grsm"></div>
</div>
<div class="col-lg-7">
<div class="visible-sm visible-md visible-lg sptxt" id="sptxt">
<?php
$post_id = 127;
$queried_post = get_post($post_id);
echo $queried_post->post_content;
?>
</div>
</div>
</div>
and the css
#spbg {
margin-top: 100px;
color: white !important;
background-image: url(http://soloveich.com/pr4/wp-content/themes/blain/images/spbg.png);
background-repeat: repeat-x;
}
#sptxt {
padding-right:20px;
padding-top: 20px;
color: #fff;
font-family: tahoma;
font-weight: bold;
line-height: 70px;
}
#gr {
width: 417px;
height: 283px;
margin-left: 30px;
margin-top: -60px;
background-image: url(http://soloveich.com/pr4/wp-content/themes/blain/images/gr.png);
background-repeat: no-repeat;
}
#splmd {
color: #fff;
font-family: tahoma;
font-size: 20px;
font-weight: bold;
text-align: center;
}
#media screen and (max-width: 1024px) {
.sptxt {
font-size:10px;
}
}
#media screen and (min-width: 1124px) {
.sptxt {
font-size:29px;
}
}
What am i doing wrong?
You're using .sptxt instead of #sptxt
#media screen and (max-width: 1024px) {
#sptxt {
font-size:10px;
}
}
#media screen and (min-width: 1124px) {
#sptxt {
font-size:29px;
}
}
You have to use the ID (#sptxt) in the media query not class (.sptxt)
#sptxt {
font-size:10px;
}
It doesn't look like anything is wrong from my browser (I'm on the latest Chrome on Windows 8.1). I'd post a picture, but I don't have the reputation for that yet.
And to others who are saying that he needs to be using the ID and not the class - why? He includes the class sptxt as well as the ID, so either one should work just fine.
It's working :- Because of white color the text disappers.
#media screen and (max-width: 1024px) {
#sptxt {
font-size:10px;
color: #000;
}
}
#media screen and (min-width: 1124px) {
#sptxt {
font-size:29px;
}
}
It works for me .. try Firefox developer tools "Responsive Design View". It's taking its 10px font-size from #sptxt class from main.css line 69
tested on Chrome 30+ also

HTML: Scalable Text

Hello I am making a website and i feel it is quite important that the text on the page is scalable for if the user has a smaller monitor or is using split screen.
I have the following HTML coding, that I believed would make it scale effectively but nothing happens?
HTML:
<p id="text">
View <a id="advertlinks" href="Prices.html">Prices</a> </br>Or <br><a id="advertlinks" href="Contact_Us.html">Book</a> A Lesson
</p>
CSS
#text
{
z-index:100;
position:absolute;
margin-top:-22%;
margin-left: 70%;
padding: 2%;
width: 22%;
height: 25%;
background-color: #f6da30;
opacity:0.6;
font-family: Impact, Charcoal, San-Serif;
font-size: 170%;
text-align: center;
-moz-border-radius: 30px;
border-radius: 30px;
}
Use CSS media queries:
#media all {
#text {
/* Default font size */
font-size: 12pt;
}
}
#media all and (max-width: 768px) {
#text {
/* Font size for smaller displays/screens */
font-size: 16pt;
}
}
Further reading: http://css-tricks.com/css-media-queries/
If you want the text to scale relative to the screen width, then your best bet is a responsive text jQuery plugin such as FlowType and FitText. If you want something light-weight, then you can use my Scalable Text jQuery plugin:
http://thdoan.github.io/scalable-text/
Sample usage:
<script>
$(document).ready(function() {
$('#text').scaleText();
}
</script>

Resources