I have two ul lists that I wrapped in divs and I want them to be side by side. There's a small icon I have left of each title that I want to float next to the title. Below is the code I have so far. It looks find when the window is large but when the window is smaller the second list is pushed under the icon before both the icon and list are pushed under the first. I don't think I formatted my css very well since ideally I would like both the second list and icon to be pushed under the first together, the moment the screen is not wide enough. How should I go about doing this?
Here's my jsfiddle https://jsfiddle.net/hw30en5z/2/
#bullet-title {
font-family: 'Oswald';
color: #004080;
font-size: 22px;
letter-spacing: 1px;
}
.table-icons {
width: 50px;
height: 50px;
margin-right: 10px;
}
#split-half {
padding-top: 2%;
margin: 0 5% 0 5%;
}
#provide {
float: left;
width: 45%;
}
#drawings {
float: left;
}
.list {
list-style: none;
padding: 0;
margin: 0;
}
.list li {
padding-left: 1em;
text-indent: -.7em;
}
.list li:before {
content: "• ";
color: #00AEEF;
}
<div id="split-half">
<img class="table-icons" src="http://animations.fg-a.com/freeicons/1-check-icon-round-purple.png" style="float:left">
<div id="provide">
<p id="bullet-title">Title 1:</p>
<ul class="list">
<li>adss</li>
</ul>
</div>
<img class="table-icons" src="http://animations.fg-a.com/freeicons/1-check-icon-round-purple.png" style="float:left">
<div id="drawings">
<p id="bullet-title">Title 2:</p>
<ul class="list">
<li>dasd</li>
</ul>
</div>
<br style="clear:both;" />
</div>
You could use responsive css to format the site when the screen has different widths. For this, you use the #media tags.
With this, you could make it so that once the screen was a certain width, both of the titles/lists go under the image.
#media (max-width: 500px) {
//css to style objects when screen is smaller than 500px
}
#media (min-width: 500px) {
//css to style objects when screen is bigger than 500px
}
Hope this helped!
You can use display:inline-block on two wrapper divs, to display 2 columns (see example below).
Some notes:
don't use inline styles like <img style="float:left"> if you can avoid it. Your code will soon be a mess, if you mix inline styles with those of your CSS file
don't use IDs multiple times, like <p id="bullet-title">. Use classes instead.
.section {
display: inline-block;
width: 200px;
}
.section > div {
display: inline-block;
}
.bullet-title {
font-family: 'Oswald';
color: #004080;
font-size: 22px;
letter-spacing: 1px;
}
.table-icons {
width: 50px;
height: 50px;
margin-right: 10px;
}
#split-half {
padding-top: 2%;
margin: 0 5% 0 5%;
}
.list {
list-style: none;
padding: 0;
margin: 0;
}
.list li {
padding-left: 1em;
text-indent: -.7em;
}
.list li:before {
content: "• ";
color: #00AEEF;
}
<div id="split-half">
<div class="section">
<img class="table-icons" src="http://animations.fg-a.com/freeicons/1-check-icon-round-purple.png">
<div id="provide">
<p class="bullet-title">Title 1:</p>
<ul class="list">
<li>adss</li>
</ul>
</div>
</div>
<div class="section">
<img class="table-icons" src="http://animations.fg-a.com/freeicons/1-check-icon-round-purple.png">
<div id="drawings">
<p class="bullet-title">Title 2:</p>
<ul class="list">
<li>dasd</li>
</ul>
</div>
</div>
</div>
Related
I cant get 2 divs on the same line but one is aligned right.
.container>* {
display: inline-block;
background-color: rgba(0, 0, 0, .85);
}
.menulinks {
font-size: 50px;
padding-top: 0px;
padding-left: 10px;
text-decoration: none;
color: blueviolet;
float: left;
}
.menulinks:hover {
color: coral;
}
<div class="container">
<div>
<img src="assets/logo.png" width="150">
</div>
<div align="right">
Photos
About
Socials
</div>
</div>
It was working before when I had tables and stuff but I thought this would be easier. They are on the same line but the links just won't align to the right,
The other answers are good in specifying that you can achieve this with flexbox.
My answer shows another flexbox approach. If you define margin-left: auto on the most right element it will always be on the right, even if you have another element right next to the logo, see the added example content.
So my answer is not better than the other ones, it just shows a different way to solve your problem. Depending on if you need more elements in a row or not, chose this approach.
.container>* {
display: inline-block;
background-color: rgba(0, 0, 0, .85);
}
.menulinks {
font-size: 50px;
padding-top: 0px;
padding-left: 10px;
text-decoration: none;
color: blueviolet;
float: left;
}
.menulinks:hover {
color: coral;
}
/*Added CSS*/
.container {
display: flex
}
.right {
margin-left: auto;
}
<div class="container">
<div>
<img src="assets/logo.png" width="150">
</div>
<div style="width: 100px; color: white">
The links are on the right even if here would be another container (with a Slogan, or some other content)
</div>
<div class="right">
Photos
About
Socials
</div>
</div>
Since there are only two divs you could use display: flex and the attribute justify-content: space-between to put all of the extra space between the only two divs.
.container {
display: flex;
justify-content: space-between;
align-items: center;
background-color: rgba(0, 0, 0, .85);
}
.menulinks {
font-size: 50px;
padding-top: 0px;
padding-left: 10px;
text-decoration: none;
color: blueviolet;
float: left;
}
.menulinks:hover {
color: coral;
}
<div class="container">
<div>
<img src="https://placekitten.com/500/500" width="150">
</div>
<div align="right">
Photos
About
Socials
</div>
</div>
Different approach with minor adjustment to your existing code is to use float:right property to the links.
Worth to mention that the attribute "align" deprecated and all layout design need to be from the style sheet.
What i did is to change the align="right" to class="right" and then added on the style sheet .right {float: right;}.
Note: since you giving your links a 50px font-size, on small screen this will span 2 lines. In order to fix this you can add #media queries
Note(2): On the break point, i changed a little the .menulinks with font-size: 25px; display: block; float: none;
So your code can look something like that:
.container > * {
display: inline-block;
background-color: rgba(0, 0, 0, .85);
}
.menulinks {
font-size: 50px;
padding-top: 0px;
padding-left: 10px;
text-decoration: none;
color: blueviolet;
float: left;
}
.menulinks:hover {
color: coral;
}
/* added: */
.right {float: right;}
#media (max-height: 480px) {
.menulinks {font-size: 25px; display: block; float: none;}
}
<div class="container">
<div>
<img src="assets/logo.png" width="150">
</div>
<div class="right"> <!-- change from align="right" that deprecated -->
Photos
About
Socials
</div>
</div>
Firstly, I highly recommend removing your general * selector. It is best to be specific when targeting elements.
I would assign specific class names to your div's. I chose item in my example below.
align="right" does not work on non-table elements. That is why this is no longer working.
Use flexbox! I've added two lines of flexbox code in your container class.
.container {
display: flex;
justify-content: space-between;
}
.item {
background-color: rgba(0, 0, 0, .85);
}
.menulinks{
font-size: 50px;
padding-top: 0px;
padding-left: 10px;
text-decoration: none;
color: blueviolet;
float: left;
}
.menulinks:hover{
color: coral;
}
<div class="container">
<div class="item">
<img src="assets/logo.png" width="150">
</div>
<div class="item">
Photos
About
Socials
</div>
</div>
Making a responsive timetable which switches to a list format for mobile, with Weekdays acting as headers and relevant sessions being listed below.
I've encountered a problem where li elements overlap. Despite experimenting with position and display values, I can't figure out how to counteract this overlap.
Any help would be appreciated.
.smallTableContainer {
position: relative;
display: none;
height: auto;
overflow: hidden;
}
.weekdayHeader {
background: #bc4b51;
color: #efefef;
font-size: 18pt;
padding: 10px 0px;
}
.sessions {
padding: 0;
}
.className {
float: left;
display: inline-block;
color: #1e1e1e;
font-size: 13pt;
padding-left: 10px;
}
.classTime {
float: right;
display: inline-block;
color: #1e1e1e;
font-size: 12pt;
padding-right: 10px;
}
<div class="smallTableContainer">
<h3 class="weekdayHeader">Monday</h3>
<ul class="sessions">
<li>
<div class="className">
Warrior Cubs Kickboxing
<br>AGES 5-7
<br>[ SPACES AVAILABLE ] </div>
<div class="classTime">
<br> 16.15pm - 17.00pm
</div>
</li>
<li>
<div class="className">
Warrior Cubs Kickboxing
<br>AGES 8-12
<br>[ SPACES AVAILABLE ]
</div>
<div class="classTime">
<br> 17.00pm - 17.45pm
</div>
</li>
</ul>
</div>
If I understand your desired result correctly, you want the events and times to disaply on individual lines. In order to do this, all you're looking for is cleart: both on your .sessions li. In addition to this, you'll probably want to add a bit of spacing between each event, which can be done by adding margin-top to the (rather complex) .sessions li:not(:first-of-type) .className selector. This ensures that the margin will be applied to all of the listings apart from the first one.
This can be seen in the following:
.smallTableContainer {
position: relative;
/*display: none;*/
height: auto;
overflow: hidden;
}
.weekdayHeader {
background: #bc4b51;
color: #efefef;
font-size: 18pt;
padding: 10px 0px;
}
.sessions {
padding: 0;
}
.sessions li {
clear: both;
}
.className {
float: left;
display: inline-block;
color: #1e1e1e;
font-size: 13pt;
padding-left: 10px;
}
.classTime {
float: right;
display: inline-block;
color: #1e1e1e;
font-size: 12pt;
padding-right: 10px;
}
.sessions li:not(:first-of-type) .className {
margin-top: 20px;
}
<div class="smallTableContainer">
<h3 class="weekdayHeader">Monday</h3>
<ul class="sessions">
<li>
<div class="className">
Warrior Cubs Kickboxing
<br>AGES 5-7
<br>[ SPACES AVAILABLE ] </div>
<div class="classTime">
<br> 16.15pm - 17.00pm
</div>
</li>
<li>
<div class="className">
Warrior Cubs Kickboxing
<br>AGES 8-12
<br>[ SPACES AVAILABLE ]
</div>
<div class="classTime">
<br> 17.00pm - 17.45pm
</div>
</li>
</ul>
</div>
I am trying to create a 3 column webpage. My bullets for the unordered and ordered lists are not aligning with the corresponding text in the column. Also, for my middle column the text is scrunched together. How do I space the paragraphs apart?
* {
font-family: Melvetica;
margin: 0px;
padding: 0px;
}
body {
background-color: #6B6A67;
}
#container {
width: 920px;
background-color: white;
padding: 10px;
margin-left: auto;
/*will center your page*/
margin-right: auto;
/*will center your page*/
}
h1,
h2 {
text-align: center;
}
li {
text-align: center;
padding: 5px;
}
h4 {
padding: 5px;
text-align: center;
}
/*To style an ID within an ID under it use the parent ID--start with header then call the ID you want to select*/
#container #header {
height: 80px;
background-color: #ADA9A0;
padding-top: 20px;
padding-left: 10px;
padding-right: 20px;
margin-bottom: 5px;
/*To add empty space to bottom of the element*/
}
#container #navigation {
margin-top: 5px;
background-color: #ADA9A0;
color: white;
padding-top: 5px;
padding-bottom: 5px;
border: 2px solid #ADA9A0;
}
#container #content {
background-color: #D9D5CE;
min-height: 300px;
margin-top: 5px;
margin-bottom: 5px;
/*To add empty space to bottom of the element*/
}
#container #content #sidebar1 {
background-color: #ADA9A0;
float: left;
width: 25%;
min-height: 300px;
margin-bottom: 3px;
}
#container #content #column1 {
background-color: white;
min-height: 300px;
margin-bottom: 3px;
width: 50%;
float: left;
margin: 0;
}
#container #content #sidebar2 {
background-color: #ADA9A0;
float: right;
width: 25%;
min-height: 300px;
margin-bottom: 3px;
}
#container #footer {
padding-top: 1px;
border-top: 1px solid black;
}
.CR {
text-align: left;
position: fixed;
}
.Instructor h4 {
text-align: right;
position: fixed right;
}
/*NAV LINKS - add an "a" to style items under the ID'S*/
#container #navigation a {
color: white;
text-decoration: none;
/*gets rid of the underlining effect*/
padding-top: 5px;
padding-bottom: 6px;
padding-left: 10px;
padding-right: 10px;
}
/*To add a hover put a:hover*/
#container #navigation a:hover {
color: red;
background-color: white;
}
#container #content #left {
font-family: Arial;
}
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="HTML.CSS.css" />
<title>My Portfolio</title>
</head>
<body>
<div id="container">
<div id="header">
<h1> CIS 2336- Internet Applications </h1>
<h2> DeVoll </h2>
</div>
<div id="navigation">
Home
HTML/CSS
PHP
</div>
<div id="content">
<div id="sidebar1">
<h4> Instuctor: Natalia Fofanova </h4>
<ul>
<li>Lectures</li>
<li>Syllabus</li>
<li>Helpful Videos</li>
</ul>
</div>
<div id="column1">
<h2> HTML and CSS </h2>
<p>HTML (Hypertext Markup Language) and CSS (Cascading Style Sheets) are two of the core technologies for bulding a website.
<p>
<p>HTML provides a structure for the page by using "Hypertext" which refers to the hyperlinks that an HTML page may contain. Also, "Markup language" refers to the way tags are used to define the page layout and elements within the page.</p>
<p>CSS provides the visual layout of web pages. They can be used to define text styles, table sizes, and other aspects of Web pages that previously could only be defined in a page's HTML. CSS helps Web developers create a uniform look across
several pages of a Web site. Instead of defining the style of each table and each block of text within a page's HTML, commonly used styles need to be defined only once in a CSS document.</p>
</p>
</div>
<div id="sidebar2">
<h4> Homework and Projects </h4>
<ul>
<li>Module 1</li>
<li>Module 2</li>
<li>Module 3</li>
<li>Welcome Button</li>
<li>2-column Webpage</li>
</ul>
</div>
</div>
<footer>
<div id="footer">
<div class="CR">
<h4> Copyright 2016 </h4>
</div>
<div class="Instructor">
<h4>Copyright Natalie Fofanova </h4>
</div>
</footer>
</body>
</html>
Declare a line-height to the 2nd section.
Example
#second p {
line-height: 20px;
}
http://www.w3schools.com/cssref/pr_dim_line-height.asp
p{
text-align: justify;
text-align-last: left;
padding-left: 10px;
padding-right: 10px;
}
Add this to your CSS hope it will work
As your code should change like the below code:
#content ul{
margin:0;
padding:0;
display:block;
}
#content ul li {
text-align: center;
padding: 0px;
list-style-type:none;/* if you really wants bullets remove this line*/
}
* {
font-family: Melvetica;
margin: 0px;
padding: 0px;
}
body {
background-color: #6B6A67;
line-height:20px;
}
#column1 p{padding:4px;}
.clearfix{clear:both;}
To change your min-height should be min-height: 320px; instead of 300px.
You want to more clarity in this question. please tell me we will suggest some more points.
i will update your code jsfiddle.
Demo
p{
padding: 0 0 10px 0;
}
just padding down would make sure space between all paragraph
I am new to web designing and I am currently designing a website for my college project.Right now, I am facing a problem which is as follow:-
When I resize the browser window,specially when i resize the browser window to a small size, the div elements jumps out of it's normal flow and everything gets scattered on giving width:100% value in my container id of CSS.
But as as i give the width of the wrapper id in pixels(say 960px), everything works and looks fine. But i want to design a full width browser window website so that it can adjust on any browser window size Please tell me how it can be done.
jsfiddle link is http://jsfiddle.net/9BuHt/3/
My CSS code is as under:-
I am new to web designing and I am currently designing a website for my college project. Right now, I am facing a problem which is as follows:
When I resize the browser window, specially when I resize the browser window to a small size, the div elements jumps out of its normal flow and everything gets scattered on giving width:100% value in my container id of CSS.
But as as I give the width of the wrapper id in pixels(say 960px), everything works and looks fine. But I want to design a full width browser window website so that it can adjust on any browser window size. Please tell me how it can be done. My CSS code is as follows:
html {
height: 100%;
width: 100%;
}
body {
margin: 0px;
padding: 0px;
background-color: #e9e5e5;
}
* {
margin: 0px;
padding: 0px;
}
#container {
min-height: 300px;
margin: 0 auto;
width: 1400px;
}
#header {
height: 150px;
width: 100%;
}
#logo {
padding-top: 10px;
padding-left: 20px;
float: left;
}
#header #title_panel {
float: left;
padding-top: 25px;
min-width: 60px;
}
#header #title_panel h1 {
color: #125ab4;
font-size: 36px;
}
#header #title_panel p {
color: #f5071d;
font-size: 20px;
font-family: "Comic Sans MS", cursive;
}
#search_panel {
margin: 10px 0px 0px 80px;
float: left;
width: 180px;
position: relative
}
#search_panel img {
float: right;
margin-top: -20px;
z-index: 1;
}
#search_field, #usrnam_field, #pwd_field {
border-radius: 20px;
color: #999;
padding-left: 4px;
s
}
#login_panel {
float: right;
width: 520px;
margin: 10px 200px 0px 0px;
min-height: 40px;
}
#login_btn, #signup_btn {
height: 20px;
width: 70px;
border-radius: 30px;
background: #125ab4;
text-align: center;
color: #FFF;
font-weight: bold;
font-family: Tahoma, Geneva, sans-serif;
font-size: 14px;
.
}
#login_btn {
float: right;
margin-top: -20px;
text-decoration: none;
}
#signup_btn {
margin: 0 auto;
}
#header h3 {
text-align: center;
padding-right: 20px;
color: #125ab4;
}
#sidebar {
min-height: 200px;
width: 136px;
margin-top: -20px;
border: solid 1px #999999;
background: #FFF;
}
#sidebar_header {
height: 32px;
background-color: #009933;
}
#sidebar_header h2 {
text-align: center;
text-decoration: none;
color: #FFF;
vertical-align: middle;
text-decoration: none;
padding-top: 2px;
}
#sidebar_header img {
position: absolute;
float: left;
margin-left: 15px;
}
#sidebar ul {
list-style: none;
}
#sidebar ul a {
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
font-weight: bold;
color: #009933;
}
#sidebar ul li {
padding-top: 15px;
text-align: center;
display: block;
vertical-align: middle;
}
#sidebar a:hover {
background-color: #009933;
padding: 10px 5px 10px 5px;
color: #FFF;
}
And the html code is as under:-
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Store-The one stock shop for all</title>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo"><img src="images/logo.png" width="100" height="100" alt="logo"></div>
<div id="title_panel">
<h1>App Store</h1>
<p>The one stock shop for all</p>
</div>
<div id="search_panel">
<form action="" method="post">
<input name="search" type="text" value="Search..." id="search_field">
</form>
<img src="images/Search_icon.png" width="22" height="22" alt="SearchIcon"> </div>
<div id="login_panel">
<form action="" method="post">
<input name="usrname" type="text" value="Username" size="30" id="usrnam_field">
<input name="psswrd" type="text" value="Password" size="30" id="pwd_field">
</form>
<a href="#">
<div id="login_btn">Login</div>
</a>
<h3> </h3>
<h3>Not a member yet?</h3>
<a href="#">
<div id="signup_btn"> Signup</div>
</a>
</div>
</div>
<div id="sidebar">
<div id="sidebar_header"> <img src="images/logo_small.png" width="22" height="28" alt="logoIcon">
<h2 style="">Store</h2>
</div>
<ul>
<li>Technologies</li>
<li>Categories</li>
<li>Developers</li>
<li>Apps</li>
</ul>
</div>
</div>
</div>
</body>
</html>
There are cases where you need to specifically fix small browser windows(this just might be one of them)
.myClass {
width: 50%;
}
but at small sizes, 50% is not big enough and we make it 100%
#media (max-width: 600px) {
.myClass {
width: 100%;
}
}
so when the browser window is less than 600px, we fix it.
here are common device sizes http://css-tricks.com/snippets/css/media-queries-for-standard-devices/
EDIT
after creating an html file of the code and looking at it, it looks like you have a 100% header with some floating elements in it.
under that you have a float left sidebar.
2 fixes that make it look a bit better are:
clear: both; on your #sidebar
and use max-width instead of width on your login_panel
so clear: both will make sure that it accounts for any element floating left or right.
max-width means that the login_panel won't get too big when the screen is huge, but when the screen it small, it won't go off-screen.
As I correctly understand you. You are need to create a fluid markup for any device support. So look to my example and try to adapt your code the same way.
So, for example you need #wrapper width = 960px for desktops and full sized content on mobile devises (if device width < 960px). So your code must be:
HTML
#wrapper {
max-width:960px;
margin:0 auto;
overflow:hidden // if you have float elements inside wrapper
}
If you have a question - welcome
I am having a very weird html problem. My main menu is not in its place.
<html>
<head>
<link rel="stylesheet" href="style5.css" type="text/css">
</head>
<body>
<div id="outer">
<ul>
<li class="current">Home</li>
<li>content</li>
<li>search</li>
<li>more</li>
</ul>
<div id="clear"></div>
</div>
<div id="wrapper">
<div id="pic">
<img src="logo.png">
<div id="content">
<p> Secure Search </p>
</div>
</div>
<div id="forms">
<form>
<input type="text" name="submit" size="78" style="font-size:20pt;"/>
</form>
</div>
</div>
</body>
</html>
and here's the css
body {
margin: 0;
padding: 0;
background-color: white;
}
h1,h2,h3 {
margin: 0;
padding: 0;
}
p,ul,ol,li {
margin: 0;
padding: 0;
}
#outer {
background-color: rgb(67,68,71);
}
#outer ul {
list-style: none;
margin-left: 5px;
border-left: 1px solid;
}
#outer li {
float: left;
}
.current {
background-color: rgb(56,63,137);
}
#outer a {
width: 90px;
display: block;
text-transform: uppercase;
text-decoration: none;
text-align: center;
font-weight: bold;
color: white;
border-right: 1px solid;
padding: 5px;
}
#outer a:hover {
color: black;
background-color: white;
}
#outer .current a:hover {
color: white;
background-color: inherit;
}
#clear {
clear: both;
}
#wrapper {
width: 960px;
margin: 0 auto;
}
#pic {
margin-top: 100px;
margin-left: 389px;
position: relative;
}
#content {
position: absolute;
top: 60px;
left: 90px;
}
#forms {
margin-top: 50px;
}
Now you may ask that how come i didn't noticed my menu not in placing during early stages of coding. Well the thing is that i was using borders on wrapper div during coding and everything was in place however as soon as i removed the border the whole thing fell apart.
I think it has something to do with the float not being cleared correctly resulting in pic div messing everything up. I would be really appreciative for your suggestions.
Thank you.
I don't know what you mean by "not in its place", but removing a border suggest you have a problem with collapsing margins.
If that's the case, you could solve it by adding overflow: auto or padding: 1px 0 to the rule where you removed the border.
Replace your
<div id="clear"></div>
with
<br id="clear">
or even better change it from and id to a class. That way you can use it multiple times.
For some reason it doesn't work with the div. But the "br" also shorter so I'd prefer that anyway.