How to remove a background URL for mobile devices - html

So I am placing a background image and then using bootstrap columns to apply text over the image.
This works fantastic on desktop but because of responsive design, the dark text sometimes goes behind dark parts of the image.
How do I remove the background URL when on mobile so only the text shows?
I know it would involve a media query but I am not sure how to hide the background image.
<div class="clearfix" style="background:transparent url(https://questsoft.com/images/default-source/sectionals/products-and-services/instanthmda_billboardc8f999a3366d6c5389a9ff00000118f1.png)no-repeat center center /cover;">
<div class="col-md-6"><br /></div>
<div class="col-md-6"><br />
<div id="global" style="text-align:left;"><br />
<p style="font-size:1.2em;">Now available in popular Loan Origination Systems</p>
<ul>
<li>Performs an instant check while the loan is being processed</li>
<li>Corrects Validity and Quality Errors at point-of-contact</li>
<li>Obtains census tract data with just one click</li>
</ul><br /></div>
</div>

You can easily do it with the help of media queries, but the way you have assigned the style, i.e. inline css is harder (quiet impossible in most of the case) to remove later by pure css. So, at first assign the style to that div externally, like this:
#content {
background: transparent url(https://questsoft.com/images/default-source/sectionals/products-and-services/instanthmda_billboardc8f999a3366d6c5389a9ff00000118f1.png) no-repeat center center /cover;
}
And, then use media queries like this (Change the max-width accordingly):
#media only screen and (max-width: 600px) {
#content {
background: none;
}
}
So, the full code goes like this:
#content {
background: transparent url(https://questsoft.com/images/default-source/sectionals/products-and-services/instanthmda_billboardc8f999a3366d6c5389a9ff00000118f1.png) no-repeat center center /cover;
}
#media only screen and (max-width: 600px) {
#content {
background: none;
}
}
<link href="http://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="clearfix" id="content">
<div class="col-md-6"><br /></div>
<div class="col-md-6"><br />
<div id="global" style="text-align:left;"><br />
<p style="font-size:1.2em;">Now available in popular Loan Origination Systems</p>
<ul>
<li>Performs an instant check while the loan is being processed</li>
<li>Corrects Validity and Quality Errors at point-of-contact</li>
<li>Obtains census tract data with just one click</li>
</ul><br /></div>
</div>
</div>
And here's the jsfiddle: http://jsfiddle.net/ruz95mef/9/

As Brian said, you can use a css media query to remove the background url for screens smaller than a certain size.
.clearfix {
background: url('images/white-zigzag.png') repeat-x;
}
#media (max-width: 600px) {
.clearfix {
background-image:none;
}
}

Related

Vertical Alignment

I am trying to align my "cards" vertically when viewed from a mobile phone however I cannot seem to get the syntax right. I tried to 'text-align: center;' float:none' among other tries but I can't seem to figure it out. Any help will be appreciated. thank you.
/* Extra small devices (portrait phones, less than 576px) */
#media (max-width: 575px) {
.card {
display: block;
float: none;
width: 100%;
text-align: center;
}
}
<div class="card">
<img src="img/websume.png" height="240" width="356" alt="Card image cap">
<p class="card-text">My "Web-sume" was my first site to include Bootstrap 4. The site is a responsive site, with a feature only available to moblie devises. The site consist of mostly Bootstrap custom layouts.</p>
</div>
<div class="card">
<img src="img/websume_drpdwn.png" height="240" width="356" alt="Card image cap">
<p class="card-text">The "Web-sume" has several fixed images as well as a drop down section which includes my address as well as social links. I used the -web kit layouts for the 'Experience' section of the site.</p>
</div>
<div class="card">
<img src="img/websume_exp.png" height="240" width="356" alt="Card image cap">
<p class="card-text">As mentioned before, the site, when viewed through a mobile devise has a feature where if a client wants to get in contact with me they do not have to scroll all the way to the bottom of the page to get my contact information, a 'email' and 'phone' button appears for easy access.</p>
</div>
Just a simple oversight - it's the CSS comment breaking your #media query. You used // Extra small devices (portrait phones, less than 576px) initially, and in CSS, the comment syntax is /* Extra small devices (portrait phones, less than 576px) */
If I understand the problem correctly, your cards are going off the edge of the screen. This is due to the fact that while you're setting the width of .card to 100% for mobiles, you're hard-coding in the widths of the images, and not actually forcing the images to be contained within the bounds of their respective .card containers.
The best way to correct this is to specify a max width for all images:
img {
max-width: 100%;
}
Note that you'll probably also want to set height: auto, to make sure that the images don't get squashed:
#media (max-width: 575px) {
img {
height: auto;
}
}
I've created a fiddle showcasing this here.
Hope this helps! :)

Adjusting elements with css according to the browser size

So I have html page like this:
I'd want to make it so that when I resize my browser or use it on a machine with different resolution the images and buttons would adjust accordingly. I guess their width should be in relationship with the browsers size somehow.
And I also want the buttons to remain in the oder listed above not that they go under each other when I resize (
At the moment the following happens:
As you might notice the map part adjusts well but I can't figure out why the buttons wont.
Here's my index.html file part:
<div class=wrapper">
<div class="toolbar">
<a href="" onclick="touch('football')"><img alt="Football"
src="images/iconsB/football.png" class="toolbarButton" /></a> <a
href="" onclick="touch('basketball')"><img alt="Basketball"
src="images/iconsB/basketball.png" class="toolbarButton" /></a>
###and so on until the end of icons###
</div>
<div class="loginbar">
<div>
<a href="#logged-in-box" class="loggedin_button"
onclick="touch('addingplaces')">Add places</a>
</div>
<div id="loggedinbutton">
<a href="#login-box" class="login-window"
onclick="showLoginForm('a.login-window')">Log in</a>
</div>
</div>
And here's my css http://pastebin.com/0DGMfnmh
Any ideas where to start? Thanks in advance!
You are looking for CSS Media Queries. With Media Queries you are able to declare CSS rules for specific resolutions only.
If you assign a class to every image, you are able to set the width of the images through media queries. Here is a quick example:
The HTML:
<img src='#' class='icon'>
<img src='#' class='icon'>
<img src='#' class='icon'>
The CSS:
/* Default rule */
.icon {
width: 64px;
height: auto;
}
/* Rules for horizontal screen resolution <= 800px */
#media (max-width: 800px) {
.icon {
width: 48px;
}
}
/* Rules for horizontal screen resolution <= 600px */
#media (max-width: 600px) {
.icon {
width: 32px;
}
}
Have a look at this link it shows you some of the basic with what you can do with media queries if you want them to wrap so going onto separate lines I would follow #Michal 's advice

Text position moving around on different sized monitors

Here's my code:
<div class="swd-layout-cell layout-item-2" style="width: 100%">
<p>
<img width="450" height="400" alt="" src="images/new.jpg" style="float: left;margin-right:20px" class="">
</p>
<h5>CloudMoV</h5>
<h6>Mobile users can import a live or on-demand video to watch from any video streaming site. </h6>
<h6>Invite your friends to watch the video concurrently. </h6>
<h6>Chat with your friends while enjoying the video.</h6>
<br>
</div>
The image appears on the left with the text on right of it. But on different sized monitors the text placement is varying.On one monitor the placement was correct and on another the text was appearing below the image.
How can I fix this?
This is being caused by width: 100%;.
HTML:
<div class="swd-layout-cell layout-item-2" style="width: 100%;">
So you have this as your container, it will strech 100% of the screen. In the demo mess around with the size of the window and you will see the text move around.
This is because when the window is lets say 500px, the image is taking up 400px. So your text is trying to get into 100px worth of space.
DEMO HERE
You can set a min-width that will stop the cotainer from getting to small so it will not squash the text.
HTML:
<div class="swd-layout-cell layout-item-2" style="width: 100%; min-width: 700px;">
So here you can see we set a min-width, this works fine as it will just stop the container from getting to small.
DEMO HERE
Another option is to use media tags. Now these are used to help design sites for all kind of resolutions.
CSS:
div {
width: 100px;
height: 100px;
}
#media screen and (min-width: 1080px) {
div {
background: blue;
}
}
#media screen and (min-width: 487px) and (max-width: 1079px) {
div {
background: green;
}
}
#media screen and (max-width: 487px) {
div {
background: red;
}
}
So this is a quick demo to show you what they do. It uses the different CSS based from the size of the screen. So using this with your code can allow you to customise the layout depending on the size of the screen.
DEMO HERE
<div class="swd-layout-cell layout-item-2" style="width: 100%;">
<p style="clear:both;">
<img alt="" src="images/new.jpg" style="float: left;margin-right:20px; width:50%; max-width:450px;" class="">
</p>
<h5>CloudMoV</h5>
<h6>Mobile users can import a live or on-demand video to watch from any video streaming site. </h6>
<h6>Invite your friends to watch the video concurrently. </h6>
<h6>Chat with your friends while enjoying the video.</h6>
<br>
</div>

Using data attributes with media queries

I have a page I am setting up so that it looks the image below on the widest resolution, however on smaller resolutions the page setup will change what images are being displayed on screen, so I wanted to use a media query and data attribute. Only problem is:
I am not sure if I am using the data attribute correctly, and
I have no idea how I would target the <p> tags with a selector so I can use :after to display the image of the badges after the text.
This cant use any jquery/jscript as a requirement so it's kind of a pain.
Demo, it should be configured properly with bootstrap. (The image is linked correctly, but not being displayed due to the attr.)
Sample HTML:
<div id="main" class=" container">
<div class="row">
<div class ="col-lg-6 " id="badgeBox">
<div class ="col-lg-12" data-test="<a href='http://www.va.gov/' target='_blank'><div class='badgeContainer'><img id='va_badge' class =' badges img-responsive' src='http://i.imgur.com/BAbUq6v.jpg'alt='Veteran Affairs Badge'></a></div>"> </div>
<span><p> U.S. Department of Veteran's Affairs</p></span>
</div>
</div>
</div>
Sample CSS:
.badgeContainer {
width: 30%;
}
#media screen and (min-width: 1200px) {
//some selector that targets the p tag// :after {
content:"("attr(data-test) ")";
}
}
I think setting content from a data attribute would work like this.. However, the data-test needs to be inside the p and you'll have the larger problem of encoding the HTML content inside data-test..
#media screen and (min-width: 1200px) {
p:after {
content: attr(data-test);
}
}
A more Bootstrap friendly approach would be to use the included utility classes (http://getbootstrap.com/css/#responsive-utilities) to only show the image link at larger resolutions use visible-lg.
Here's a demo with both approaches: http://bootply.com/94916

Even out space layout (table)

For a web application I'm creating (in Umbraco, but don't think that really matters in this case) I need a page that can show an overview of different media types; audio, video and images.
No problem there, for images and videos (hosted on YouTube) I will show a thumbnail and for audio I will show a static image.
The rough layout of an item will be that the image is shown on top, and below that is some info like the title and a short description.
Now because of the difference in dimensions of the images (thumbnails can have a variable size, the audio static image will probably always be smaller than the thumbnails, etc.) one item (or column if you will) can be of less width than another.
What I would like to do is show three items per row, and when the row isn't completely filled I would like to fill it up with a colored box. But that box should not always be at the end, it could also be in between, or the beginning. It just is inserted 'randomly' when a space fill is needed.
Because a picture says more than 1000 words (wire-frame of what I'm trying to describe);
Now my question; is this at all possible? If yes, how?
I can't wrap my mind around it, it can't be done in pure HTML and CSS I think. Because you couldn't determine how big an item is and if a 'filler' is needed.
The rough HTML I have right now is something like this:
<table id="portfolio">
<tr>
<td>
<div class="portfolioItem">
<div class="portfolioItemImage">
<a rel="prettyPhoto" href="http://www.youtube.com/watch?v={video}"><img src="http://img.youtube.com/vi/{video}/1.jpg"/></a>
</div>
<br clear="both" />
<div class="portfolioItemDescription">
<h3>Title</h3>
<p>Description lorem ipsum etc.</p>
</div>
</div>
</td>
</tr>
</table>
Of course there is some more dynamic stuff in there to determine whether it is a video, audio or image, determine when to start a new row, etc. but that isn't relevant here.
Here is the CSS associated with it:
#portfolio {
width:100%;
}
#portfolio td {
width:33%;
}
#portfolio .portfolioItem {
border: 1px solid #000;
}
#portfolio .portfolioItem .portfolioItemImage {
margin:0px;
padding:0px;
}
Again; can this be done? And how?
Thank you!
I think that what you want is jQuery Masonry or the Wookmark jQuery Plugin.
I would create the grid using DIVs instead of TABLES, regardless I think this is what you are looking for?:
#portfolio td
{
min-width:33%;
}
EDIT:
Here is a rudimentary example of a grid created with DIV's:
http://jsfiddle.net/rdtnU/
<div class="con">
<div class="row">
<div class="cell">a</div>
<div class="cell">b</div>
<div class="cell is_last">c</div>
</div>
<div class="row">
<div class="cell">d</div>
<div class="cell">e</div>
<div class="cell is_last">f</div>
</div>
</div>
.con {}
.row { width:340px; margin:0 0 20px 0; overflow:hidden; }
.cell { width:100px; margin:0 20px 0 0; float:left; background:orange; }
.is_last { margin:0; }​
I would use the div's as suggested but I would not limit myself to the row/columns as stated. I would use a more fluid layout even if it is for a specified width of a certain section.
The following will only work if you know the width of the div with the content, to allow the floating to occur (this could work if there is a min-width or if your code can determine the size of the image)
Here is the HTML
<div class="elements">
<div class="singleElement">
text and graphics here.
</div>
<div class="singleElement">
text and graphics here.
</div>
<div class="singleElement">
text and graphics here.
</div>
<div class="singleElement">
thisonewillpushthewidthoftheboxfartherthanthe150pxwidth
</div>
<div class="singleElement">
small text
</div>
</div>
Here is the CSS (I put some simple background colors so you can see what is going on with the width and how things are tucked in where space is available.
.elements { overflow: hidden; width: 500px; background: #FCC; }
.singleElement { padding: 5px; white-space:nowrap; float: left;
height: 200px; min-width: 100px; background: #CCC;margin: 0 10px 10px 0; }
Please note the details of the styles are just for demonstrating the example. They can be altered to fit your need.
EXAMPLE: Here is the example in jsFiddle.