Vertical Alignment - html

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! :)

Related

Increase Title Margin in Mobile view only

Everything looks great on desktop. But in the mobile view I'm seeing blog titles overlapping the blog teasers on my blog page. I am trying to add margins to the bottom of the blog post titles for the mobile view only:
I've tried adding this css:
#media all and (max-width: 1000px) and (min-width: 700px) { .entry-container .entry-title { margin-bottom:15px; }}
but that doesn't seem to do anything.
Here is a copy of the div with its classes:
<div class="entry-container"><header class="entry-header"><h2 class="entry-title"><a class="entry-title-link" rel="bookmark" href="https://avt.850.myftpupload.com/why-we-became-financial-advisors/">Why We Became Financial Advisors</a></h2>
</header><div class="entry-content"><p>Would you hand over your house keys to a stranger? That’s often what it feels like to work with a financial advisor. Not only do …</p><p class="more-link-wrap">Continue Reading <span class="screen-reader-text">about Why We Became Financial Advisors</span></p></div><footer class="entry-footer"><div class="alignleft"><img alt="" src="https://secure.gravatar.com/avatar/895fdbf242e920205673491b0b5b2b80?s=46&d=mm&r=g" srcset="https://secure.gravatar.com/avatar/895fdbf242e920205673491b0b5b2b80?s=92&d=mm&r=g 2x" class="avatar avatar-46 photo" height="46" width="46" loading="lazy"></div><p class="entry-meta"><span class="entry-author">Written by:<br><span class="entry-author-name">Kourtney Kearney</span></span><span class="entry-date"><time class="entry-time">Published on:<br><span class="entry-time-date">September 2, 2021</span></time></span> <span class="entry-comments-link">Thoughts:<br>No comments yet</span></p></footer></div>
Just review the provided Test link, the issue is not related to Title or Responsive.
Actually margin-top: -60px!important; CSS added on .entry-content and margin-bottom: 65px; CSS on .entry-header.
Step 1:
Remove margin-top: -60px!important; CSS from .entry-content.
Step 2:
Change margin-bottom: 65px; CSS to margin-bottom: 0; on .entry-header.
Will resolve your issue on Both Desktop and Responsive versions. Thank You
There are couple of things you can check:
min-width: 700px to max-width: 1000px is not mobile view. It is usually tablet size. So if you're checking on smaller screen sizes, your CSS might not get applied.
As you can see in the snippet you pasted, normal divs will be positioned correctly one after the other without an overlap even when there is no margin set. So check if you've have a height set on .entry-container, .entry-header, .entry-title h2.entry-title. This is probably causing the header to overflow and thus overlap on the content below.

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

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>

CSS/HTML - Hide images on mobile phone and use an alternate text

I currently have a page that generates a table from an SQL database using PHP, including one column that contains images. Due to us now having to work on a mobile platform, I'm looking for a way to hide the images. I'm currently using display: none on an antiscreen.css file, but as the images are links, it doesn't show the links
For clarity, when the image is on a PC browser it appears like this:
<td>
<a href="link to image source:>
<img height=80 alt='Text I want to display' src="link to image source" />
</a>
</td>
And when on a mobile the image, link and text are hidden using the display:none method.
So how would you recommend I work this out?
I would probably do this:
<td>
<a href="link to image source:>
<img height=80 alt='Text I want to display' src="link to image source" />
<span class="mobileonly" src="link to image source">Text I want to display</span>
</a>
</td>
Then I would set span.mobileonly { display: none; } on the main stylesheet and span.mobileonly { display: inline; } in antiscreen.css. The advantage is that the mobile link will also be easy to style.
Another option, which works for all screen sizes under a certain nr. of pixels is to use a media query, basically similar to the above one but with the advantage that it works on any screen size smaller than the defined number of pixels.
/* Media Query for mobile */
#media screen and (max-width: 480px) {
/* This resizes tables and images to be 100% wide with a proportionate width */
/* Hide stuff on mobiles */
table[class=emailnomob],td[class=emailnomob],img[class=emailnomob],span[class=emailnomob]{display:none !important;}
/* Additional Media Query for tablets */
#media screen and (min-width: 480px) and (max-width: 1024px) {
/* Hide stuff on tablets */
table[class=emailnomob],td[class=emailnomob],img[class=emailnomob],span[class=emailnomob]{display:none !important;}
This should covers both mobile and tablet devices.
Code courtesy of .net email tutorial. I only stripped the parts you don't need.
Usage:
<img class="emailnomob" height=80 alt="Text I want to display" src="link to image source" />