keep position on different resolution - html

Hi i got this image gallery and information that should be seen on the right side of the pictures. i floated them both as left. my default resolution is 1366 x 768. it turned out ok. but if i change it to 1024 x 768, the information keeps going down, i need to keep the information on the right side of the image even though other users have different resolutions. here is the code, can some help me?
HTML
<div id="home_page_images">
<div id="home_page_images_slider">
<img src="images/accred_images/image_1.JPG" alt="In the office with the evaluators" />
<img src="images/accred_images/image_2.JPG" alt="Evaluating faculties" />
<img src="images/accred_images/image_3.JPG" alt="CCS students OJT" />
<img src="images/accred_images/image_4.JPG" alt="Packaging of hard documents" />
<img src="images/accred_images/image_5.JPG" alt="Meeting of the evaluators" />
</div>
</div>
<div id="home_page_content_frame">
<div id="home_page_content">
<span>Welcome to the QCE and CCE Evaluation System</span>
<p>The CCE Evaluation process, also known as "Accreditation", is a voluntary, non-governmental process that includes an external review of a professor’s ability to provide quality programs. It is helpful in many aspects, from ensuring that students are learning relevant material to allowing a school access to funding. Accreditation reviews include self-evaluations, peer-reviews, committee-reviews, and the development of in-depth strategic plans. They also include reviews of a school’s mission, faculty qualifications, and curricula.</p>
</div>
</div>
CSS
#home_page_images {
position: relative;
width: auto;
margin-top: 40px;
margin-left: 40px;
float: left;
}
#home_page_content_frame {
float: left;
width: auto;
}
#home_page_content p {
text-align: justify;
position:relative;
}

On your divs, you could use percentages instead of pixels like robobobobo said, but then if you are making it for mobile devices, you would probably want to use media queries as mobile devices are small, and if you decide to use something like 50% for desktop devices, it would be really small, example of media queries:
#div {
width:375px;
}
#media screen and (min-width: 1366px) {
#div {width:375px;}
}
#media screen and (min-width: 1440px) {
#div {width:428px;}
}
#media screen and (min-width: 1600px) {
#div {width:434px;}
}
#media screen and (min-width: 1920px) {
#div {width:540px;}
}
Change the (min-width: 1920px) part to the minimum or maximum size you want the code to be fore.

Related

responsiveness in html and css #media query

I'm trying to create 3 different scenario's. Small screen, medium screens and large screens.
#media screen and (max-width: 400px) {
.message-large, .message-med { display: none; }
}
#media screen and (min-width: 401px) and (max-width: 1099px) {
.message-large, .message-small { display: none; }
}
#media screen and (min-width: 1100px) {
.message-small, .message-med { display: none; }
}
The way it works as coded above, large scenario works on large display. medium scenario works on medium display. medium scenario works on small display <-- there is where the problem occurs.
<img class="message-small" src="message-small.png" width="1100" height="392" alt="Hover over this image or click on it to receive a PRO-TIP.">
<p class="message-small">small</p>
<img class="message-med" src="message-med.png" width="1100" height="392" alt="Hover over this image or click on it to receive a PRO-TIP.">
<p class="message-med">medium</p>
<img class="message-large" src="message-large.png" width="1100" height="392" alt="Hover over this image or click on it to receive a PRO-TIP.">
<p class="message-large">large</p>
The p's are just to troubleshoot the issue. The img src width and height will be resized accordingly later on, haven't got that far yet.

How To Use Multiple Media Queries Within A Css Class In Less?

I have a less file containing a simple css class that needs to have different styles applied for various screen sizes. The following code only works on desktop (the first #desktop media query). Nothing happens for mobile. I have tried many variations of this syntax with no luck and haven't found anything about this in the docs. You can also see the live demo here (notice how if you stretch the screen wider than 1024px the div turns orange, but it does not turn red or green when smaller than 1024px as it should). Thanks.
html
<div class="derp">
Hello
</div>
less
#desktop-min-width: 1024px;
#phone-max-width: 768px;
#desktop: ~"only screen and (min-width: #{desktop-min-width})";
#tablet: ~"only screen and (min-width: #{phone-max-width}) and (max-width: #{desktop-min-width}";
#phone: ~"only screen and (max-width: #{phone-max-width})";
#appHeight: 749px;
#appWidth: 421px;
.derp {
#media #desktop {
background-color: orange;
}
#media #tablet {
background-color: red;
}
#media #phone {
background-color: green;
}
}
There is a problem with
#tablet: ~"only screen and (min-width: #{phone-max-width}) and (max-width: #{desktop-min-width}";
Remove it for a moment, and you will see green background is displayed for phone screen.
You need to add ")" for a #tablet at the end

CSS - Optimizing constant screensize changes on the same item to increase performance

A screenshot is below of the webpage that I need to optimize the screen sizes for. The horizontal bar above the navigation bar with the logos, white background and the clubs on the left is what I'm wanting to optimize the screen size CSS code for. I've only started working with html and css a few month ago.
Webpage
From 1230px the margin-left increases by 0.8px. Is there a way to increase the webpages performance with the 35+ "#media screen and (min-width: #px)" that will be needed to cater to screen min-width of 1930px or more? Or will this many not affect the pages performance at all?
/* Team Logos spacing for different screen sizes */
#media screen and (min-width: 1200px)
{
.clubs .llul .logoli
{
margin-left: 0px;
}
}
#media screen and (min-width: 1210px)
{
.clubs .llul .logoli
{
margin-left: 0.45px;
}
}
#media screen and (min-width: 1220px)
{
.clubs .llul .logoli
{
margin-left: 0.9px;
}
}
#media screen and (min-width: 1230px)
{
.clubs .llul .logoli
{
margin-left: 1.3px;
}
}
#media screen and (min-width: 1250px)
{
.clubs .llul .logoli
{
margin-left: 2.1px;
}
}
.
.
./* Rest of code between 1250px and 1630px */
.
.
#media screen and (min-width: 1630px)
{
.clubs .llul .logoli
{
margin-left: 17.3px;
}
}
#media screen and (min-width: 1650px)
{
.clubs .llul .logoli
{
margin-left: 18.1px;
}
}
I've also added a snippet of the code behind the element. The rest of the CSS for it is not shown.
<div class="clubs">
<p style="display: inline;">Clubs</p>
<ul class="llul">
<li class="logoli"> <img class="logoT" style="" src="media/teams/smlafel.JPG" alt="fl">
<ul class="llul">
<li class="logoli" style="padding-left: 10px;"> <b>Africa Elite</b> </li>
<li class="logoli"> <img class="logoT" style="" src="media/teams/smlafel.JPG" alt="fl"> <b>Africa Elite</b> [Men's Premier Division] </li>
</ul>
</li>
</ul>
</div>
Please don't do stuff like that. You're just copying & pasting your code for .clubs .llul .logoli and adjusting the margin-left rule every 10px. There's definitely something wrong with that from a programming point of view. This does not affect the performance (well, maybe when resizing your browser window vary fast), but your CSS file will be much messy and heavier than it has to be, so when the browser will download this file at the beginning, then loading the page, it can take a while.
The solution here is to go with this:
#media screen and (max-width: 1200px) {
.clubs .llul .logoli {
margin-left: 0px;
}
}
#media screen and (min-width: 1200px) {
.clubs .llul .logoli {
margin-left: calc((100vw - 1200px) / NUMBER_OF_ELEMENTS);
}
}
Where 100vw is always the window width (from CSS's point of view). So when it's bigger than 1200px, you get the size you want to share between all your logos and divide it by some constant than can be the number of those logos, more or less than that. You can adjust it as you like.
Even more clever way to go with this is to take a look at display: flex and justify-content rules. I'll leave this link here for more infos:
https://tailwindcss.com/docs/flexbox-justify-content/
Hope this was useful, good luck!
Why don't you use svg for the logos if you have them in that format, they will scale up and down to perfection and read like code, therefore no optimisation required

Responsive CSS- Different Layout for Different Size

So, I basically want to have 2 different layouts for a page on my website.
For under 400px:
[image]
description
[image]
description
For above 400px:
[image] description
[image] description
(so, the image and the text are on the same line)
I know I can do this very easily with Bootstrap if my breakpoint was one of the predefined ones, but it is not. So, what would the best approach be? Could I still use Bootstrap grid system and 'hack' it somehow or do something else altogether?
Thanks!
Here is a snippet
/*screen width over 400px*/
#media (min-width: 401px){
img {
width:50px;
height:50px;
}
p{
display:inline;
}
}
/*screen upto 400px*/
#media (max-width: 400px){
img {
width:100px;
height:100px;
}
}
<img src='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSSHCRPXAtpOWvSaR4T5ecblzIT-RdIV19VjNB4uUPPnEq_UT5r'>
<p id='p1'>
description
</p>
<img src='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQEaoUONNbTby87bfUNcRrdufGcaLSbDnC3SGSqKLk1ZwNFMEE3'>
<p id='p2'>
description
</p>
Alright your going to have to use media queries. Here are a few examples that I wrote.
A media query is a set of styles(styles that you set)that has a certain screen size condition.
When this screen size condition is met the styles given inside the media query override any other styles that contradict the styles outside the media query.
Here is an example
#media (max-width: 500px) {
#visible {
display: none;
}
}
<p id="visible">Not Hidden</p>
<p>Change screen sizes!</p>
Here is the basic syntax of media queries
First make the #media then add a screen size condition (max-width: 1000px) or (min-width: 500px) heres an example using max-width. Then, add the styles inside the media query.(Dont forget to close the media query!)
#media (max-width: 1000px) {
h1 {
display: none;
}
#hidden {
display: block;
}
}
p {
display: none;
}
<h1 id="heading">Heading</h1>
<p id="hidden">Hidden</p>
Now run the code snippet above and you will see that the heading will appear when the screen size is above 1000px and it disappears and a hidden phrase appears when the screen size is below 1000px.
Here is a tutorial on media queries Media Queries
What you're looking for are css media queries. Check this page for an in-depth explanation http://www.w3schools.com/cssref/css3_pr_mediaquery.asp.
Alternatively, in your case it looks like you simply want to wrap the descriptions on to the next line when the viewport becomes too narrow. If this is the case then there's no need to add in extra markup because you can just leverage the natural behavior of inline-block elements. This link will clarify the behavior of inline-block elements for you http://www.w3schools.com/css/css_inline-block.asp.
I would go this way, using a row structure.
It will give you some more options down the road, when/if you maybe want 3 img/text lined up, or ... and so on, sooner or later maybe a header, maybe a footer.
.header {
padding: 10px;
border-bottom: 1px solid #999;
}
.container {
padding: 10px;
white-space: nowrap;
}
.container .row {
margin-bottom: 10px;
}
.container .row span {
margin-left: 10px;
}
.container .row.at-top span {
vertical-align: top;
}
#media (max-width: 400px){
.container .row span {
display: block;
margin-left: 0;
margin-top: 10px;
}
}
<div class="header">
<div class="row">
Header
</div>
</div>
<div class="container">
<div class="row at-top">
<img src="http://lorempixel.com/200/100/sports" />
<span> Some text ... being aligned at top</span>
</div>
<div class="row">
<img src="http://lorempixel.com/200/100/city" />
<span> Some text ... or at bottom</span>
</div>
</div>

Having trouble with css media queries

I want to hide my menu icon on smartphone screens but the media query isn't working. Can anyone shed some insight?
I tried looking at some other answers on here but nothing really helped as I am checking it by re-sizing my browser but I'm using max-width so it should still show.
I have three different logos. One for desktop, one for tablet, and one for mobile. Right now I'm trying to hide my desktop logo for mobile and it's not working so I thought I would try to find out why before trying to hide/reveal any more images.
UPDATE: SOLVED. I'm not sure why it works but after constant refreshing and 30 minutes later it works.
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
#menu-logo {
display: none;
}
}
<div id="header" class="header">
<img id="menu-logo" src="../images/logo.svg"/>
<img id="menu-logo-semi" src="../logo-semi.svg"/>
<img id="menu-logo-small" src="../logo-short.svg"/>
</div
There's no need to have 3 links.
A better way to do this is as follows:
<div id="header" class="header">
<a class="logo" href="/index.html">My cool name</a>
</div>
<style>
<!-- Desktop -->
.logo {
display: block;
text-indent: -9999px;
width: 200px;
height: 82px;
background: url(logo.svg);
background-size: 100px 82px;
}
<!-- Tablet -->
#media all and (max-width: 64em) and (min-width: 48em) {
.logo {
width: 80px;
height: 60px;
background-size: 80px 60px;
}
}
<!-- Mobile -->
#media all and (max-width: 48em) {
.logo {
width: 50px;
height: 30px;
background-size: 50px 30px;
}
}
</style>
Cleaner code.. Just change your logo sizes as you need.
EDIT
I don't know if your logo changes visually on each screen resolution interval. If so, just state another "background: url ..." rule on each media query, before the "background-size". If not, it will be ok since it's a vector, as long as the proportions are correct.
The cause is most likely due to CSS specficity, and the order of things in your stylesheet(s). We need to see all of the CSS affecting the #menu-logo item, and the img generally, especially the default (ie non-media query) CSS, and any other media queries that affect this menu-logo item.
And we also need to know whether such CSS comes before or after the media query - the order of things is very important. (NB: I know really this would be better as a comment rather than a full answer, but I don't have enough rep for that yet!)
So look at the specificity, and the order, then if still flummoxed give us more of the CSS (or the whole stylesheet if it isn't too long).