First of all, I just wanted to say this page is for a Web Design course.
I have icons for social media in a responsive page I'm building, and I've applied a max-width:3% to all of them to reduce their original size, as they were too big before. Now, as I reduce the size of the window, I would like the icons stay responsive while retaining their new size. However, the icons scale as well, making them appear too small. I know I could use pixels to define a fixed size, but one of the objectives of this exercise is to not set image values in pixels (just allowed for padding values).
Is there a way to achieve this?
My html codes
<div id="footwrap">
<footer>
<div id="footh3">
<h3 class="h3">Follow me on social media:</h3>
</div>
<div id="footlink">
<a href="http://www.facebook.com" target="_blank">
<img src="images/facebook-icon.svg" alt="Facebook">
</a>
<a href="http://www.instagram.com" target="_blank">
<img src="images/instagram-icon.svg" alt="Instagram">
</a>
<a href="http://www.youtube.com" target="_blank">
<img src="images/youtube-icon.svg" alt="YouTube">
</a>
<a href="http://www.twitter.com" target="_blank">
<img src="images/twitter-icon.svg" alt="Twitter">
</a>
</di>
</footer>
</div>
My CSS style:
#footwrap {
clear: both;
padding: 2%;
}
footer {
position: relative;
clear: both;
text-align: center;
width: 100%;
height: 8em;
margin-top: 12%;
}
#footh3 {
display: inline-block;
}
footer h3 {
display: inline-block;
font-family: 'Open Sans', sans-serif;
font-size: 1.17em;
margin-bottom: 2em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
#footlink {
display: inline-block;
}
footer a {
text-decoration: none;
}
footer img {
display: inline-block;
max-width: 3%;
height: auto;
margin-left: 1.5%;
margin-right: 10px;
vertical-align: middle;
}
The desired outcome would be how the icons in the top right corner of this page react when the web browser window is reduced: http://www.omganeshaya.com/
You can use media queries to adjust to a higher percentage as the page gets smaller. see fiddle: https://jsfiddle.net/622r62mp/
For more information about media queries you can reference this site https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
CSS example
img{max-width:3%}
#media (max-width: 1000px){
img{max-width:9%}
}
#media (max-width: 600px){
img{max-width:15%}
}
Related
I'm tried to used responsive aviatar for my main page in website, everything works well except the figcaption that giving problems both in desktop view and media query.
Any suggestion or workaround I should modify.
.breakpoint { /* One column for smartphones */
max-width: 33%;
display: inline-block;
margin: 4px;
}
.breakpoint figcaption {
text-align: center;
padding-top: 5px;
font-style: italic;
font-size: 8px;
text-indent: 0;
}
<section id="responsive-images-breakpoints">
<a href="public_transport/index.htm">
<img class="breakpoint avatar" src="images/airport-kix/airport-bus.jpg" alt="Public Transport">
<figcaption>Public Transport</figcaption>
</a>
The figcaption element should be embedded inside the figure element.
Example:
<figure>
<img src="" alt="">
<figcaption></figcaption>
</figure>
I'm trying to create a top bar with the following structure
Tel:4949494949 social media icons
In the middle I'm trying to have contact info and at almost in right my social media icons.
I'm not able to place social media in right. CSS always gets them to the middle, next to contact info.
What is wrong?
#tpbr_box .a {
width: 10%;
height: 20%;
text-align: center;
display: inline;
font-size: 20px!important;
}
#tpbr_box .social2 {
float: right;
}
#tpbr_box {
font-size: 20px!important;
}
<div class="info">
<i class="fa fa-home"></i> |
<a style="color:white;" href="tel:54543">354353535</a>
</div>
<div class="social2">
</div>
I switched out the div classes because when you use a new one, it writes itt in a new line. I fixed this by using a a-class instead of a div, still giving an class to each one. The reason why I used width and margin-left with percents is no matter the length, the html will adjust(ex. you resize the window, it resizes with it).
.topbar {
width: 100%
}
.info {
margin-left: 45%
}
.social2 {
margin-left: 55%
}
<div class="info">
<a class='center'>
<i class="fa fa-home"></i>
354353535
</a>
<a class='social2'>
f
t
i
y
</a>
</div>
Based on your requirements, Info to the middle, and social to the right side!
Try this:
<!-- Html code -->
<div class="top_nav">
<div class="info">
<i class="fa fa-home"></i> |
<a style="color:whites;" href="tel:54543">354353535</a>
</div>
<div class="social2">
</div>
</div>
And here is the CSS style:
#tpbr_box .a {
width: 10%;
height: 20%;
text-align: center;
display: inline;
font-size: 20px!important;
}
#tpbr_box .social2{
float:right;
}
#tpbr_box {
font-size: 20px!important;
}
.top_nav{
display: flex;
}
.top_nav .social2 {
position: absolute;
right: 14px;
}
.info{
margin: 0 auto;
}
Make sure add parent div with "top_nav" class to control the style.
I think the problem comes from the fact that you put a text-align: center; on your links. Putting a text-align: center; on the tags a, all your links present on your page will go to the middle.
In my jquery Mobile app, I've got a page that has a header and footer and the main content is 4 images arranged 2x2. I chose to create my own 2x2 grid in a div since I couldn't get JM grid to work. The code for the main content looks like this:
<div class="container">
<div class="image">
<a href="#intro">
<img src="img/Intro1.png" />
</a>
</div>
<div class="image">
<a href="#putting">
<img src="img/Putting1.png" />
</a>
</div>
<div class="image">
<a href="#chipping">
<img src="img/Chipping1.png" />
</a>
</div>
<div class="image">
<a href="#sand">
<img src="img/SandPlay1.png" />
</a>
</div>
</div>
The page css that arranges everything looks like this:
.container {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
.container .image {
width: 50%;
}
.container img {
width: calc(100% - (5px * 2));
margin: 5px;
}
This works fine on an iPhone, but the images are too large on an iPad. On the iPad the images are the full width which makes them go beyond the bottom edge of the screen. I've looked all over for a solution to this and finally decided to come here. Thanks in advance for any help/guidance.
What you'll want to use is media queries. For the issue with the ipad you can set the media queries so that if your page is being viewed on a tablet/ipad size you can specify the size of the images and anything else. Take a look at this example:
.sample {
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
color: #ffffff ;
font-size: 7rem;
position: absolute;
top: 17%;
width: 100%;
}
#media screen and (max-width: 900px){
.sample {
font-size: 3.5rem;
margin: auto;
width: 50%;
padding-bottom: 100px;
}
}
In the above you can see the class of sample (both outside and inside the media query) has different css styles based on the screen size.
Take a look at this for further info: https://www.w3schools.com/css/css_rwd_mediaqueries.asp
This question already has an answer here:
Responsive width is too small on phone, but okay on desktop browser
(1 answer)
Closed 6 years ago.
I have:
<div style="min-width: 1000px;">
<p>
Some text
</p>
<div class='div_img_left'>
<img src="images/sth.png" alt="missing image" style="max-width: 100%;">
<footer>My caption</footer>
</div>
</div>
.div_img_left {
max-width: 50%;
float: left;
margin-right: 30px;
margin-bottom: 2em;
text-align: center;
}
It is looking fine on my PC's screen. The problem begins when I open it on my mobile phone. As I suppose the issue here is that I don't have 1000px screen width on the phone. So everything shrinks. The problem is that "Some text" looks fine. Unfortunately "My caption" shrinks significantly more. How can I solve this?
I tried using other geometrical constraints but I failed. Specifically using % or min-height.
Use media queries and don't set things at such a large min-width if you want to have a responsive site. Use vw for width.
.div_img_left {
max-width: 50vw;
float: left;
margin-right: 30px;
margin-bottom: 2em;
text-align: center;
}
figcaption {
font-size: 1em;
line-height: 1.3;
text-align: center;
}
#media (max-width: 500px) {
figcaption {
font-size: 14px;
line-height: 1
min-width: 100%;
}
figure {
min-width: 100vw;
}
}
<div style="width: 100%;">
<!--changed from min-width: 1000px-->
<p>
Some text
</p>
<figure class='div_img_left'>
<img src="http://placehold.it/150x200/eea/e00?text=150x200" alt="missing image" style="max-width: 100%;">
<figcaption>My caption</figcaption>
</figure>
</div>
How do I automatically space the pictures to the size of the screen ' html
Yeah please post your html and css.
Otherwise what is really useful if your making a gallery is to crop your pictures to equal height and width, and then add
img{
width:100%;
}
I would avoid setting the height unless you make all your pictures equal height as it may make responsive a little funky. Height should automatically be set by the size of the containing element if the width is set to 100%;
Ths is an example to get images evenly & horizontally in a Div via CSS;
CSS
#thumbs {
width: 540px;
margin-top:90px;
margin-left: auto;
margin-right: auto;
text-align: justify;
-ms-text-justify: distribute-all-lines;
text-justify: distribute-all-lines;
}
#thumbs a {
vertical-align: top;
display: inline-block;
*display: inline;
zoom: 1;
}
.stretch {
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0
}
HTML
<div id="thumbs">
<a id="single_image1" href="#"><img src="http://dummyimage.com/150x150/444/fff" alt=""/></a>
<a id="single_image2" href="#"><img src="http://dummyimage.com/150x150/444/fff" alt=""/></a>
<a id="single_image3" href="#"><img src="http://dummyimage.com/150x150/444/fff" alt=""/></a>
<span class="stretch"></span>
</div>