Text position moving around on different sized monitors - html

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>

Related

How to remove a background URL for mobile devices

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;
}
}

Adjust Bootstrap image resizing

I am trying to make a card div with two images inside, an up arrow and a down arrow.
When in full screen the images look okay and are the full size but due to Bootstraps responsive design, when i reduce the page resolution using the developer console in chrome, the images get smaller and smaller until they cannot be seen on a small device, such as a mobile.
How can i limit how small the images will go?
Thanks.
<div class='col-11 col-xs-11 col-md-5 col-lg-5' style='background-color:#dfdfdf;border-radius:5px;margin-right:10px;margin-bottom:10px;'>
<div class='col-2 col-xs-2 col-md-2 col-lg-2'>
<h4 class='card-header' style='text-align:center;height:100%;'>
<img style='height:50%;'src='uparrow' onmouseover=this.src='differentuparrow' onmouseout=this.src='uparrow' border='0'/>
<br><br>
<img style='height:50%; src='downarrow' onmouseover=this.src='differentdownarrow' onmouseout=this.src='downarrow' border='0'/>
</h4>
</div>
<div class='col-8 col-xs-8 col-md-8 col-lg-8'>
<h4 class='card-header' style=''><u>Title</u></h4>
<div class='card-body' style=''>
<p class='card-title'>Description</p>
<p class='card-text' style='display: inline-block; bottom:0;'>Points: 0<br>Replies: 0</p>
</div>
</div>
<div class='col-2 col-xs-2 col-md-2 col-lg-2' style='float:right;'>
<i class='fa fa-pencil fa-5' aria-hidden='true'> Edit</i>
<br> <i class='fa fa-trash fa-5' aria-hidden='true'> Delete</i>
</div>
</div>
https://jsfiddle.net/5a87h3ky/
I had to remove the original sources for the images due to confidentiality
You can set the minimum size of the image using the min-width: px; attribute.
This will prevent the image from getting any smaller than the given size.
There are several ways of controlling the size of images with CSS or in HTML. To control your arrows you can use min-height and max-height and also set min-width and max-width.
For example take image_arrow_up.jpg, you can set it's size with:
<head>
<style>
div {
max-height: 600px;
min-height: 400px;
max-width: 400px;
min-width: 200px;
}
</style>
</head>
Another way would be to use percentages, although this is not as concrete as min and max:
<!DOCTYPE html>
<html>
<head>
<style>
html, body {
height: 100%;
}
img.one {
height: auto;
width: auto;
}
img.two {
height: 50%;
width: 50%;
}
</style>
</head>
<body>
Another option is to use CSS with the image-set function, or with scrset + sizes:
.img {
background-image: url(examples/images/image-384.jpg);
background-image:
-webkit-image-set(
url(examples/images/image-384.jpg) 1x,
url(examples/images/image-768.jpg) 2x,
);
background-image:
image-set(
url(examples/images/image-384.jpg) 1x,
url(examples/images/image-768.jpg) 2x,
);
}
It also helps to make sure the original image is sized appropriately. For example make the original arrow image sized for a "regular" desktop monitor rather than an oversized arrow that may shrink in unexpected ways. Or you can use an image management service, such as Cloudinary or 3Scale to create responsive quality images.

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

Changing size of div container with zoom on tablet

I have a web page with questions on it. I want the user to be able to use a 7" Android tablet (with Chrome) to answer the questions. Some people will want to zoom. Some will not.
How can I get the div container to resize (wrapping the text inside the borders of the screen) when the user zooms in or out? I tried this:
.resizcontainer {
width: 90%;
background: #CEE;
margin: 0 auto; /* the auto value on the sides, */
}
with the top of the code as this:
<body>
<div class="resizcontainer" style="border: thin black solid">
<div class="header">
<h2>Risk Assessment Test</h2>
</div>
<div class="content">
I'm not sure if it matters, but Chrome on the desktop does the job just fine. The container resizes just fine. Or is it because this is a form???