Text over Image - Make is responsive for smaller screens - html

I'm very new to programming and I'm trying to modify my Retina template to customize my Shopify store. It's been fun so far and have had good results!
However I'm stuck on this question: How do I make my code responsive?
I managed to add the HTML and CSS codes to have text over image, but I can't figure out to make it responsive (text automatically adjust its size) for smaller screens (ex. mobile)
HTML Code
<div class="textoverimage">
<img src="xxxxxx" alt="xxxx">
<h7> TEXT </h7>
</div>
CSS Code:
/* #Custom Styles
================================================== */
.textoverimage {
position: relative;
width: 100%;
}
h7 {
position: absolute;
top: 75px;
left: 0;
width: 100%;
text-align: center;
}
I used h7 not to interfere with any preexisting codes (Shopify used h1-h6)

You can attain it through media queries.
#media only screen and (max-width:500px) {
h7 {
        font-size:14px;
    }
}
This will make the font size of the h7 to 14px when the screen width drop below 500px.

If your making custom css in shopify then you need both image and text responsive
Here is your answer for make them both responsive Live On FIDDLE.
.img-reponsive {
display: block;
max-width: 100%;
height: auto;
margin: 0 auto;
}
.textoverimage {
position: relative;
}
p.title {
position: absolute;
top: 75px;
left: 0;
text-align: center;
font-size: 38px;
width: 100%;
color: #fff
}
#media only screen and (max-width: 767px) {
p.title {
font-size: 1.5em;
line-height: 1.5em;
}
}
#media only screen and (max-width: 479px) {
p.title {
font-size: 1.1em;
line-height: 1.1em;
}
}
<div class="textoverimage">
<img class="img-reponsive" src="http://cdn.shopify.com/s/files/1/0258/1101/t/2/assets/slideshow_3.jpg?5808719635421587686" alt="xxxx">
<p class="title"> TEXT </p>
</div>

Related

When applying media queries, nothing is getting adjusted

I'm extremely confused because I am pretty certain that I have it set up correctly. It doesn't set the font to 10 pixels on my phone and when I adjust the screen. Am I missing something?
Here's the code:
.above-email-box {
/* aligns text to the center with position absolute */
text-align: center;
position: absolute;
margin-top: 90px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
font-family: 'Glory', sans-serif;
font-family: 'Klee One', cursive;
font-size: 30px;
}
#media only screen (min-width: 768px) {
.above-email-box {
font-size: 10px;
}
}
Thanks.
.above-email-box {
/* aligns text to the center with position absolute */
text-align: center;
position: absolute;
margin-top: 90px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
font-family: 'Glory', sans-serif;
font-family: 'Klee One', cursive;
font-size: 30px;
}
#media only screen and (max-width: 768px) {
.above-email-box {
font-size: 10px;
}
}
<div class="above-email-box"> Demo Text</div>
Logical operators
The logical operators not, and, and only can be used to compose a complex media query. You can also combine multiple media queries into a single rule by separating them with commas.
You have to define max-width & min-width consciously, sometime it can be confusing, min-width means when you add styles into it, it display the styles after the min-width condition is met, if you define min-width:500px your styles are applicable on screens width 500px and above not below
In order to run the media query for mobile device you need to change min-width to max-width like below
#media (max-width: 768px) {
.above-email-box {
font-size: 10px;
}
}
When your screen width is below 768px it will change font-size to 10px

CSS - media queries / RWD , logo image file hiding behind fixed nav

I'm working on the media queries for a site and I'm stuck on a static logo image which sits within the header but only when the screen size is min-width 960px.
Above that size I have an interactive particle logo image but when the screen is reduced down to mobile-size I just want a logo in the header. The problem is the logo simply isn't showing. I suspect it is being hidden by the nav bar which is fixed in position.
This is how I have my code at the moment -
<header>
<div id="logo"> <img src="images/havoc_logo.png"> </div>
<nav>
Home
What we do
Who we are
Who we work with
Say hello
Blog
</nav>
</header>
styles.css/media queries
#logo {
width: auto;
height: auto;
}
#logo img {
width: 200px;
height: 100px;
}
/* RWD for logo (particle-slider is id for interactive logo) */
#media screen and (max-width: 960px) {
#particle-slider {
display: none;
}
}
#media screen and (min-width: 960px) {
#logo img {
display: none;
}
}
#media screen and (max-width: 480px) {
body {
max-width: 500px;
}
header {
height: auto;
}
nav {
text-align: center;
padding-bottom: 10px;
padding-top: 10px;
}
nav a {
display: block;
border-bottom: 0;
}
#logo {
height: auto;
}
#logo img {
width: 200px;
height: 100px;
}
So, when I shrink the page right down to 480px or less then nothing shows in the header other than the nav bar. How do I show the logo image in the header when I shrink the page?
I found the answer with this Q&A here
Basically my nav was held in a fixed position and covering the logo so I had to revert the position:fixed rule to position:static

Body media query doesn't work

I have a navigation bar which has padding to allow content to display under the navigation bar. For mobiles I want to lessen the padding but the media query doesn't seem to work. Any ideas to why?
Example:
body{
padding-top: 70px;
}
p.t{
color: white;
background-color: black;
top: 0px;
position: absolute;
}
#media only screen and (max-width: 767px) {
.body {
padding-top: 0px;
}
}
<body>
<p class="t">
This is my pretend navbar woo.
</p>
<p>
hello
</p>
</body>
You're doing .body instead of body. By using .body, the CSS is searching for an element with class="body", instead of an element <body>. Simple fix:
#media only screen and (max-width: 767px) {
body {
padding-top: 0;
}
}

Use Mobile menu (burger) on mobile and tablet sizes for a foundation 5 site

I'm sure this has been asked but I can't seem to find an example that isn't using SASS. I just have a regular CSS file that I'm working with. I want the burger menu to change to the horizontal menu on the larger size.(#media only screen and (min-width: 64.063em)) I've seen a few posts saying to update the settings.scss file like this(http://foundation.zurb.com/forum/posts/1483-customize-topbar-breakpoint-in-scss) but again I'm not using SASS for this project. I just can't seem to figure out what is triggering the menu to change from mobile to desktop: media queries or javascript.
If you want to use CSS you can override the Foundation CSS in a separate CSS file (ie:styles.css) section that follows the foundation.css
Demo on Codeply
#media only screen and (max-width: 64.063em) {
.top-bar {
overflow: hidden;
height: 2.8125rem;
line-height: 2.8125rem;
position: relative;
background: #333;
margin-bottom: 0;
}
.top-bar-section {
left: 0;
position: relative;
width: auto;
transition: left 300ms ease-out;
}
.top-bar-section ul {
padding: 0;
width: 100%;
height: auto;
display: block;
font-size: 16px;
margin: 0;
}
.top-bar .toggle-topbar.menu-icon {
top: 50%;
margin-top: -16px;
display:block;
}
.top-bar .title-area {
float: none;
}
}
http://codeply.com/go/OtVVMn0n6V
If you don't want to use SASS, then you'd better change foundation.css file.
Around line 1682 change it from
meta.foundation-mq-topbar {
font-family: "/only screen and (min-width:40.063em)/";
width: 40.063em;
}
to
meta.foundation-mq-topbar {
font-family: "/only screen and (min-width:64.063em)/";
width: 64.063em;
}
Also around line 2006, change it from
#media only screen and (min-width: 40.063em) {
To
#media only screen and (min-width: 64.063em) {

Iphone responsive website issue

I am creating a new website, here is the www.qldmetals.com
Everything seems to be fine on website except its responsiveness on iPhone. In iPhone the logo sits over the navigation menu. I tried the following media query, but it doesn't seems to be working for me i.e
#media only screen
and (min-device-width : 320px)
and (max-device-width : 568px) { .logo a.brand { display: block !important; }}
I'm confuse, Is this error because of display method or anything else (like I have to use media query for any other class)
I appreciate your help and your valuable time.
Thank you.
I have seen your website and after that i have created some of my own style element which i am sharing it's only for media screen max width 480px
Following Code
#media (max-width:480px){
.logo a.brand {
display: block !important;
height: auto;
line-height: 30px;
margin: 0;
overflow: hidden;
padding: 0;
width: auto;
}
.logo a.brand img {
float: none;
height: auto;
margin: 2px 8px 2px 0;
width: 100%;
}
header .logo{
float: none;
max-height: none;
text-align: center;
width: 100%;
}
}