Web site responsiveness issue with images and right aligned text - html

I've tried to make my website responsive but I am running into two major issues.
I have a right aligned text that disappears off the screen when I reduce the width of the window instead of remaining aligned. I've tried margin-right: auto; but it doesn't work. This right aligned text I want to make responsive is also on the same line as a <li> item
<li><h3>Kid's menu<span class="tabbed_text">25,50 lei</span></h3> </li>
<li><h3>Menu #1<span class="tabbed_text">25,50 lei</span></h3> </li>
<li><h3>Menu #2<span class="tabbed_text">25,50 lei</span></h3></li>
<li><h3>Menu #3<span class="tabbed_text">25,50 lei</span></h3></li>
This is the html I used
.tabbed_text{
display:inline-block;
font-family: "caveat";
font-size: 30px;
position:absolute;
left:1750px;
}
li{
font-family: "cattie";
font-weight: bold;
font-size: 25px;
}
this is the css use for them
This is how they look like on screen
The second issue is related to an image:
This it how it looks like on fullscreen but when I shrink the window it ends up like this:
this is the css I used for the image:
.small_logo{
width: 150px;
height: auto;
position:absolute;
top:3%;
left:34%;
}

Issue 1: You set span tag is position:absolute;left:1750px;
=> so you can not make it responsively when you shink.
HTML:
<ol>
<li>
<div>
Kid's menu
<span class="tabbed_text">25,50 lei</span>
</div>
</li>
</ol>
CSS:
div {
font-family: "caveat";
font-size: 30px;
display: flex;
justify-content: space-between;
}
a {
font-family: "caveat";
font-size: 30px;
}
li {
font-family: "cattie";
font-weight: bold;
font-size: 25px;
}
You can see the sample here:
Issue 2: I will help when you clear your question!

Related

How to fix the text absolutely in HTML/CSS even I minimize the screen

So right now I am trying to apply what I have learned in Front Web Development, and I have this problem where the text doesn't stay the way it should be in smaller viewports.
body {
font-family: "Roboto Condensed", sans-serif;
margin: 0;
background: #f2f2fc;
color: #302e4d;
}
.about-section {
position: absolute;
max-width: 100%;
top: 20%;
left: 40%;
transform: translate(-40%, -60%);
}
.about-me div {
font-size: 40px;
font-weight: bold;
}
.intro {
font-size: 30px;
padding-top: 50px;
font-weight: bold;
}
.intro-stud {
color: #E00;
}
.description {
color: #504e70;
font-size: 20px;
font-weight: normal;
}
<div id="main-content">
<section class="about-section">
<div class="about-me">
<div>About Me</div>
</div>
<div class="intro">
<span class="intro-name">I'm Christian Wells Martin and</span>
<span class="intro-stud">a Student</span>
<p class="description">Hi! My name is Christian Wells Martin, a BSIT/BSCS student in _____ College/University, and currently studying web development, and this website is my first mini-project, and I hope you guys will like it!.</p>
</div>
</section>
</div>
Recommendations are welcome, specially if I am doing some wrong practices.
There are a couple ways to solve this.
One, you're using percentages in your absolute positioning. Percentages will change as the size of the window changes. This can make for a nice effect, but it doesn't seem to be what you're going for. Try using exact pixel values if you don't want your text to react responsively. https://www.w3schools.com/cssref/pr_dim_width.asp
Another, more advanced way to solve this would be to use media queries. These allow you to define different css styles based on the current size of the screen. https://www.w3schools.com/cssref/css3_pr_mediaquery.asp
.about-section{
display:grid;
grid-template-rows:auto, 1fr;
}
That should solve your problem. If it is not try this one:
.about-section{
display:flex;
flex-direction:column;
}

Removing the black bar between divs and having them share a background image

I am trying to design a weather website. In the body I have a div for my search bar, and then a div below it for the main area with the weather information. The problem is that there is a divider between the two (below the search area and above the main area) How do I get rid of this? I have tried margins but I can't figure out what I'm missing.
As well, I am trying to get these two divs to share one background image
Thanks in advance
<div class="searchArea">
<ul>
<li><div><input type="text" id="search_term" placeholder="Other Location ..."></div></li>
<li><div><input type="submit" value="Check Weather" onclick="findNewWeather()" /></div></li>
</ul>
</div>
<div class="mainArea">
<h1>City Name</h1>
<ul>
<li>
<div>
<h1>Current</h1>
<img src="http://openweathermap.org/img/wn/10d#2x.png" alt="today icon">
<h2>12oC</h2>
<h3>Feels: 9oC</h3>
<h3>Mostly Sunny</h3>
ETC ....
.weatherMain {
margin-top: 1px;
background-image: url("./WP.jpg");
background-size: 100%;
background-repeat: no-repeat;
color: gray;
padding: 25px0px;
display: flex;
flex-direction: row;
height: 600px;
font-family: poiret one;
font-size: 35px;
color: yellow;
font-weight: bold;
}
.searchArea {
background-image: url("./banff.jpg");
background-position: 0 -75;
height: 50px;
margin-bottom: 1px;
}
Given the code you posted above, I think the problem is that your <ul> and <h1> tags have their own margins that are pushing your <div> tags apart.
This should fix the issue:
.searchArea ul {
margin-bottom: 0;
}
.weatherMain h1 { // or .mainArea h1, your example has both
margin-top: 0;
}
To give them one background, I would recommend wrapping them in a <div> and applying the background image to that.

HTML & CSS Centering Text and Image Together

I'm getting into the field of web design, and for practice purposes, I'm trying to create responsive HTML and CSS websites modeled after real websites so I only worry about the development, not the design. As of now, I'm redesigning apple.com. My problem is that in the apple.com navigation bar, the Apple logo is consistently around an inch away from the links to other parts of the site. As you resize the browser, it stays around an inch away. The problem is that on my (unfinished) version of the site, the apple logo stays fixed in one position as you resize the browser.
Here's my code:
html {
font-size: 100%;
}
body {
padding: 0;
margin: 0;
}
#font-face {
font-family: "San Francisco";
font-weight: 400;
src: url("https://applesocial.s3.amazonaws.com/assets/styles/fonts/sanfrancisco/sanfranciscodisplay-regular-webfont.woff");
}
.font {
font-family: San Francisco;
}
.logo {
position: absolute;
left: 5em;
top: .5em;
}
.center {
display: inline;
text-align: center;
}
.search {
display: block;
position: fixed;
right: 1em;
top: .7em;
}
header {
list-style-type: none;
word-spacing: 40px;
background-color: #323232;
height: 2.8em;
width: 100%;
position: fixed;
opacity: .98;
}
.ul-header {
margin: .8em;
}
.li-header {
display: inline;
}
.a-header {
text-decoration: none;
color: white;
font-family: San Francisco;
font-size: 15px;
}
.iphoneximg {
display: block;
margin-left: auto;
margin-right: auto;
}
.iphone {
text-align: center;
font-size: 3em;
line-height: 0.5em;
}
.sayhello {
text-align: center;
font-size: 1.6em;
line-height: 0;
font-weight: 550;
}
#media(min-width: 1500px) {
.iphoneximg {
width: 50%;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Apple</title>
<link rel="icon" href="Images/Apple.ico">
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<header>
<div class="center">
<img src="Images/Screenshot%20from%202018-03-20%2020-59-01.png" class="logo">
<ul class="ul-header">
<li class="li-header">Mac</li>
<li class="li-header">iPad</li>
<li class="li-header">iPhone</li>
<li class="li-header">Watch</li>
<li class="li-header">TV</li>
<li class="li-header">Music</li>
<li class="li-header">Support</li>
<img src="Images/Search.png" class="search">
</ul>
</div>
</header>
<br><br><br><br><br><br><br><br><br>
<section class="iphonex">
<h1 class="font iphone">iPhone X</h1>
<p class="font sayhello">Say hello to the future.</p>
<img src="Images/iphone.png" width="76%" class="iphoneximg">
</section>
<section class="iphonex">
<h1 class="font iphone">iPhone 8</h1>
<p class="font sayhello">A new generation of iPhone.</p>
<img src="Images/generation.jpg" width="76%" class="iphoneximg">
</section>
</body>
</html>
Someone suggested this solution:
How to horizontally center a <div> in another <div>?
The problem is that I'm trying to figure out how to work with the differences between images and text to center them, so simply throwing them in a div won't work.
I've tried putting the text and the image in a div and centering it, % values, messing with the display property, and a few other things, but nothing seems to work.
I'm also a newbie web dev, so if there's anything else I should fix, feel free to let me know.
Thanks,
Lyfe
Run an inspect element on the Apple page and you'll see they place their image as another list element. You on the other hand are placing it outside your list.
Here is your code, with the Apple logo placed as the first list element:
<ul class="ul-header">
<li class="li-header"><img src="apple_logo.png" width='20px'></li>
<li class="li-header">Mac</li>
<li class="li-header">iPad</li>
<li class="li-header">iPhone</li>
<li class="li-header">Watch</li>
<li class="li-header">TV</li>
<li class="li-header">Music</li>
<li class="li-header">Support</li>
</ul>
EDIT
To ensure your apple logo aligns vertically with the other elements in your list, add this to your CSS:
#app_logo {
margin-top: -10px;
}
.center ul img {
vertical-align: middle;
}
Note I added an ID to the image. Also, your settings may be slightly different.
if we have an actual look at the CSS and HTML of the apple page this is how you do it:
html:
<ul class="ac-gn-list">
<li class="ac-gn-item ac-gn-apple">
<a class="ac-gn-link ac-gn-link-apple" href="/" data-analytics-title="apple home" id="ac-gn-firstfocus">
<span class="ac-gn-link-text">Apple</span>
</a>
</li>
<li class="ac-gn-item ac-gn-item-menu ac-gn-mac">
<a class="ac-gn-link ac-gn-link-mac" href="/mac/" data-analytics-title="mac">
<span class="ac-gn-link-text">Mac</span>
</a>
</li>
<li class="ac-gn-item ac-gn-item-menu ac-gn-ipad">
<a class="ac-gn-link ac-gn-link-ipad" href="/ipad/" data-analytics-title="ipad">
<span class="ac-gn-link-text">iPad</span>
</a>
</li>
... There are More...
</ul>
css:
#media only screen and (max-width: 767px){#ac-globalnav .ac-gn-item-menu{
height:43px;
border-bottom:1px solid #333;
opacity:0;
pointer-events:none;
}
.ac-gn-apple{
position:absolute;
width:48px;
top:0;
left:50%;
margin-left:-24px;
text-align:center;
z-index:1
}
Comment:
I would bet the
position:absolute;
does the trick, however, I cut out allot of the webkit code. If yo ureally want to make a dynamic page/responsive page, you need to learn the Bootstrap Library, it is honestly super easy to use and to start using. Makes everything dynamic and responsive.

Text with different sizes on same line, how to align smaller text horizontally central with bigger text?

As demonstrated in the above image (please take no notice of the fact the Dasboard text is abhorrently large - I only made it that size for this example), I want the text that says "Admin Control Panel" to be aligned horizontally middle with where the Dashboard text is, online with the red arrow.
The code I have for both these pieces of text are:
<div id="content-breadcrumb">
Admin Control Panel »
<span id="active">
Dashboard
</span>
</div>
The CSS code is:
#content-breadcrumb {
font-family: 'Varela Round', sans-serif
font-size: 16px;
}
#content-breadcrumb #active {
font-size: 200px;
color: #4F95C4;
}
Note that I have tried using vertical align and setting line height to no avail. Thanks for any help that you can offer!
You can use flex box and align-items to accomplish this:
(PS: your closing div and span tags are missing the right caret)
#content-breadcrumb {
display: flex;
align-items: center;
font-size: 1rem;
}
#active {
font-size: 2rem;
}
<div id="content-breadcrumb">
Admin Control Panel »
<span id="active">
Dashboard
</span>
</div>
If you dont want to use flex-box you can use vertical-align: middle;.
https://jsfiddle.net/yrduwpzm/
#content-breadcrumb {
font-family: 'Varela Round', sans-serif
font-size: 16px;
}
#content-breadcrumb #active {
font-size: 50px;
color: #4F95C4;
vertical-align: middle;
}
<div id="content-breadcrumb">
Admin Control Panel »
<span id="active">
Dashboard
</span>
</div>

Align header element alongside image

I have a small menu panel that needs to be included on my page that looks like the image below:
I have the code in a jsFiddle that I have created so far and I know some of the images are incorrect but the issue is I cannot get the header to align neatly to the right of the image as shown in the image.
Any clues?
Changed 2 properties:
ul.block-with-icons span {
display: block;
font-size: 11px;
line-height: 1.2em;
position: relative;
top: 12px;
}
h5 {
font-size: 16px;
position: absolute;
left: 98px;
top: 30px;
}
http://jsfiddle.net/wRkdL/25/
If you are developing in HTML5, I think the best option is to move <h5> inside <a> tag like this:
<li class="b1">
<a href="#">
<h5>Our background</h5>
<span>A little background info on who we are...</span>
</a>
</li>
In HTML4 it's not allowed to insert a block element inside anchors.