Can someone please tell me why my 'header' div and 'pageInnerWrap' div are overlapping...been messing about with position absolute but cant get it...any help appreciated...ta
<div id="pageWrap">
<div id="pageInnerWrap" class="push">
<div id="header" class="push">
<div class="inner-wrap">
<a id="A2" href="Home.aspx"><img src="/images/logo_new.png" alt="Azi Map" /></a>
<div style="position:relative;float:right">
<%--Login Stuff--%>
<div class="loginDisplay" style="width:33%">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
<img src="/images/btn_login.png" alt="Login" />
Login |
<a id="A4" href="~/Account/Register.aspx" runat="server" title="Sign up for your 30 days free trial">Free Trial</a>
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold"><asp:Label id="UserLogonID" runat="server"></asp:Label></span>,
<br />
[<asp:HyperLink ID="hlChangePassword" runat="server" NavigateUrl="~/Account/ChangePassword.aspx">Change Password</asp:HyperLink>]
[<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out" LogoutPageUrl="~/Home.aspx"/>]
<br />
</LoggedInTemplate>
</asp:LoginView>
<p style="text-align:right">
<asp:Label ID="lblFreeTrialDays" runat="server" Text=""></asp:Label>
</p>
</div>
</div>
<ul id="nav">
<li><img src="/images/btn_layers.png" alt="Layers" />Layers</li>
<li><img src="/images/btn_maps.png" alt="Layers"/>Maps</li>
<li><img src="/images/btn_admin.png" alt="Layers"/>Admin</li>
</ul>
<div id="mobile-btn">
<img src="imgs/menu_btn.png" alt="Menu Button" />
</div>
</div>
</div><%--header--%>
<div style=" margin: 0 auto; width: 2000px; height: 1200px">
<div id="mainContent" class="main" style="background:white;">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
<div style= "visibility:hidden;>
<div id="AlertDiv" class="AlertStyle">
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/loading.GIF"/>
</div>
</div>
</div>
</div>
</div>
<div id="mobile-nav-items">
<ul>
</ul>
</div>
</div>
CSS
* {
box-sizing: border-box;
}
html, body, div {
border: 0 none;
margin: 0;
padding: 0;
}
body { padding-top:150px; }
#pageWrap { position: relative; }
#pageInnerWrap { position: relative; }
div#header { background:#1E4964; color:#fff; font:14px/1.5em Arial, sans-serif; font-weight:600; position:fixed; width:100%; top:0; }
div#header .inner-wrap { max-width:1900px; margin:0 auto; width:95%; padding:0 2.5%; }
div#header a { color:#fff; position:relative; text-decoration: none; }
div#header a:active { top:1px; }
header #page-header-top { background:#000; }
header #page-header-top .inner-wrap { padding-top:10px; padding-bottom:10px; height:40px; text-align:right; overflow: hidden; }
header #page-header-top .inner-wrap a { background:#153447; }
header #page-header-top img { position: relative; top:4px; left:-4px; }
header #page-header-top a:hover { text-decoration: underline; }
header #mobile-btn { display:none; }
header a#logo { float:left; margin:38px 0; }
div#heade ul#nav { float:right; margin:0; }
div#heade ul#nav li { display:inline-block; text-align:center; }
div#heade ul#nav li a { padding:20px 30px; display:inline-block; }
div#heade ul#nav li a:hover { background:#185070; }
div#heade ul#nav li a#active { background:#153447; }
div#heade ul#nav li a img { margin:0 auto 20px; display:block; }
header .clear { clear:both; }
#mobile-nav-items { display:none; }
#mobile-btn { display:none; float:right; margin:35px 0; padding:10px 10px 5px; cursor: pointer; position: relative; }
#mobile-btn:active { top: 1px; }
#media only screen and (max-width : 1200px) {
header ul#nav li a { padding-left:20px; padding-right:20px; }
}
#media only screen and (max-width : 950px) {
header #mobile-btn { display:block; }
header #mobile-btn:hover { background:#153447; }
header #mobile-btn.menu-open { background:#153447; }
header #mobile-btn img { width:20px; }
#mobile-nav-items {
display:block;
}
ul#nav { display: none; }
}
/* change on scroll */
div#header,
div#header * {
-webkit-transition: all 0.3s ease-in;
-moz-transition: all 0.3s ease-in;
-o-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
}
header.scrolled #page-header-top .inner-wrap { height:0; padding-top:0; padding-bottom:0; }
header.scrolled a#logo { margin:12px 0 5px; }
header.scrolled ul#nav li a img { height:0; margin:0; }
header.scrolled #mobile-btn { margin:10px 0 3
px; }
Not surprised you have a problem with this code, get your indentation right, I think you're missing a closing </div> and there's a missing quotation mark:
<div style= "visibility:hidden;>
I tried to clean it up, but gave up, only you know which part should be where.
For example put siblings on the same tabulation level:
<div id="header" class="push">
<div class="inner-wrap">
<a id="A2" href="Home.aspx"><img src="/images/logo_new.png" alt="Azi Map" /></a>
<div style="position:relative;float:right">
...
</div>
...
<div />
</div>
</div>
Also on SO, you need 4 spaces or a tab before your code block, but not more, just look at your question, half of the code is unnecessary leading whitespace.
Related
I need to adjust footer like the image shown below in four columns as it is. Trying to do but the last two columns are not meeting like the first as shown in the image. Tried to make them in a single row with four columns but unable to adjust it like the sample image shown below. Please help with this.
HTML CODE:
<!-- Site footer -->
<footer class="site-footer">
<div class="container">
<div class="row">
<div class="col-xs-6 col-md-3">
<h6>Categories</h6>
<ul class="footer-links">
<li>C</li>
<li>UI Design</li>
<li>PHP</li>
<li>Java</li>
<li>Android</li>
<li>Templates</li>
</ul>
</div>
<div class="col-xs-6 col-md-3">
<h6>Quick Links</h6>
<ul class="footer-links">
<li>About Us</li>
<li>Contact Us</li>
<li>Contribute</li>
<li>Privacy Policy</li>
<li>Sitemap</li>
</ul>
</div>
</div>
<hr>
</div>
<h2>Join our newsletter</h2>
<h6>Join our newsletter and Stay informed to latest news and events</h6>
<div id=footer>
<input type="text" id="fname" name="firstname" placeholder="Enter your Email:">
<input type="submit" value="Submit">
</div>
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="col-md-8 col-sm-6 col-xs-12">
<img src="http://cache1.artprintimages.com/images/jump_pages/rebrand/footer/fb.png" href="#">
<p class="copyright-text">Excoboard extended community 2014 | Privacy Policy
</p>
</div>
<ul class="social-icons">
<li><a class="facebook" href="#"><i class="fa fa-facebook"></i></a></li>
<li><a class="twitter" href="#"><i class="fa fa-twitter"></i></a></li>
<li><a class="dribbble" href="#"><i class="fa fa-dribbble"></i></a></li>
<li><a class="linkedin" href="#"><i class="fa fa-linkedin"></i></a></li>
</ul>
</div>
</div>
</div>
</footer>
CSS CODE:
input[type=text] {
width: 15%;
padding: 12px 20px;
margin: 8px 0;
display: block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=submit] {
width: 15%;
background-color: #0000FF;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
#footerabout {
border-radius: 5px;
padding: 20px;
}
.site-footer
{
background-color:#26272b;
padding:45px 0 20px;
font-size:15px;
line-height:24px;
color:#737373;
}
.site-footer hr
{
border-top-color:#bbb;
opacity:0.5
}
.site-footer hr.small
{
margin:20px 0
}
.site-footer h6
{
color:#fff;
font-size:16px;
text-transform:uppercase;
margin-top:5px;
letter-spacing:2px
}
.site-footer a
{
color:#737373;
}
.site-footer a:hover
{
color:#3366cc;
text-decoration:none;
}
.footer-links
{
padding-left:0;
list-style:none
}
.footer-links li
{
display:block
}
.footer-links a
{
color:#737373
}
.footer-links a:active,.footer-links a:focus,.footer-links a:hover
{
color:#3366cc;
text-decoration:none;
}
.footer-links.inline li
{
display:inline-block
}
.site-footer .social-icons
{
text-align:right
}
.site-footer .social-icons a
{
width:40px;
height:40px;
line-height:40px;
margin-left:6px;
margin-right:0;
border-radius:100%;
background-color:#33353d
}
.copyright-text
{
margin:0
}
#media (max-width:991px)
{
.site-footer [class^=col-]
{
margin-bottom:30px
}
}
#media (max-width:767px)
{
.site-footer
{
padding-bottom:0
}
.site-footer .copyright-text,.site-footer .social-icons
{
text-align:center
}
}
.social-icons
{
padding-left:0;
margin-bottom:0;
list-style:none
}
.social-icons li
{
display:inline-block;
margin-bottom:4px
}
.social-icons li.title
{
margin-right:15px;
text-transform:uppercase;
color:#96a2b2;
font-weight:700;
font-size:13px
}
.social-icons a{
background-color:#eceeef;
color:#818a91;
font-size:16px;
display:inline-block;
line-height:44px;
width:44px;
height:44px;
text-align:center;
margin-right:8px;
border-radius:100%;
-webkit-transition:all .2s linear;
-o-transition:all .2s linear;
transition:all .2s linear
}
.social-icons a:active,.social-icons a:focus,.social-icons a:hover
{
color:#fff;
background-color:#29aafe
}
.social-icons.size-sm a
{
line-height:34px;
height:34px;
width:34px;
font-size:14px
}
.social-icons a.facebook:hover
{
background-color:#3b5998
}
.social-icons a.twitter:hover
{
background-color:#00aced
}
.social-icons a.linkedin:hover
{
background-color:#007bb6
}
.social-icons a.dribbble:hover
{
background-color:#ea4c89
}
#media (max-width:767px)
{
.social-icons li.title
{
display:block;
margin-right:0;
font-weight:600
}
}
I have used a 12 column format. (refer the web view image) there are two divs marked in yellow and red each has a width of 50% each.
I have coded it in such a way that when the device width has reduced the width of each divs will be set to 100% so that the content in each of the div sections are placed one below the other when viewed from a mobile or any device with lesser width. But as seen in the screenshot of the mobile view(1 & 2) that is not the case. the second div has moved out of the screen.
I have not used any bootstrap. My HTML and CSS codes are as follows
/********DEFAULTS*******/
nav,header,footer
{
display:block;
}
body
{
line-height: 1;
margin :0;
}
/********NAV BAR*******/
nav
{
width:100%;
margin:0;
}
nav ul
{
background-color: #eee;
overflow: hidden;
margin:0;
padding:0;
}
ul.topnav li
{
list-style: none;
float : left;
margin:0;
padding:0;
}
ul.topnav li.topnav-right
{
float : right;
}
ul.topnav li a
{
display : block;
text-decoration : none;
min-height:16px;
text-align:centre;
padding:14px;
text-transform: uppercase;
color:#665;
}
ul.topnav li a:hover
{
background-color: #0000ff;
color:#fff;
}
ul.topnav li.dropdownicon
{
display: none;
}
.container
{
width : 100%;
margins: auto;
padding-top: 4%;
padding-bottom: 4%;
background:
}
/********custom style*******/
#section-1-gradient
{
background:#076DFF;
background-image: -webkit-linear-gradient(#076DFF, #65A5FF);
background-image: -o-linear-gradient(#076DFF, #65A5FF);
background-image: -moz-linear-gradient(#076DFF, #65A5FF);
background-image: linear-gradient(#076DFF, #65A5FF);
}
h1.large
{
color:#fff;
font-size: 56px;
margin:0;
line-height: 70px;
}
div.leftside-col
{
margin-left:30%;
}
div.rightside-col
{
margin-left:15%;
}
input[type="text"]
{
font-size: 20px;
width:400px;
min-width: 100px;
padding:5px;
}
input[type="password"] /* added by shamil*/
{
font-size: 20px;
width:400px;
min-width: 100px;
padding:5px;
}
form h2
{
color:white;
}
.row
{
width:100%;
display:flex;
flex:wrap;
align-items:center;
}
.row::after
{
display:table;
clear: both;
content:"";
}
.col-1{width:8.33%;}
.col-2{width:16.66%;}
.col-3{width:25%;}
.col-4{width:33.33%;}
.col-5{width:41.66%;}
.col-6{width:50%;}
.col-7{width:58.33%;}
.col-8{width:66.66%;}
.col-9{width:75%;}
.col-10{width:83.33%;}
.col-11{width:91.66%;}
.col-12{width:100%;}
/********MOBILE*******/
#media screen and (max-width : 680px)
{
ul.topnav li:not(:nth-child(1))
{
display: none;
}
ul.topnav li.dropdownicon
{
display:block;
float: right;
}
ul.topnav.responsive li.dropdownicon{
position: absolute;
top:0;
right:0;
}
ul.topnav.responsive{
position: relative;
}
ul.topnav.responsive li{
display:inline;
float : none;
}
ul.topnav.responsive li a
{
display: block;
text-align: left;
text-transform: uppercase;
}
.col-6
{
width:100%;
margin:0;
}
div.rightside-col,
div.leftside-col
{
width:15%;
}
}
<! DOCTYPE html>
<html>
<head>
<title>
Anime Shop
</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav>
<ul class="topnav" id="dropdownClick">
<li>Home</li>
<li>News</li>
<li>Contact</li>
<li>About</li>
<li class="topnav-right">Sign up</li>
<li class="topnav-right">Sign in</li>
<li class="dropdownicon">☰</li>
</ul>
</nav>
<div class="container" id="section-1-gradient">
<div class="row">
<div class= "col-6">
<div class= "leftside-col">
<h1 class="large">
Crazy radness
</h1>
<h1 class="large">
Made for Otaku
</h1>
<form>
<div class= "leftside-col">
<h2>Username</h2>
<input class="inputbox" type="text" name="Username "placeholder="Username">
<h2>Password</h2>
<input class="inputbox" type="password" name="Password "placeholder="Password">
</div>
</form>
</div>
</div>
<div class= "col-6">
<div class= "rightside-col">
<iframe width="560" height="315" src="https://www.youtube.com/embed/uC_SgMzlr6U" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
<script>
function dropdownMenu()
{
var x= document.getElementById("dropdownClick");
if(x.className === "topnav")
{
x.className = "topnav responsive";
/*change topnav to topnav.responsive*/
}
else
{
x.className = "topnav";
}
}
</script>
</body>
</html>
Can someone please point out where I am going wrong?
you can add below code to your media query
.row {
flex-direction: column;
}
then just fix your margin and paddings
what I found is its taking 50% of the size even when it is in a smaller size and as there will be a minimum width so it is overflowing to the left try to make it reactive
Following is the all in one code i.e. html and style. Question is that why the "Box" div is being overlapped on to the "Footer" div. You can copy paste the code and see it yourself in the browser. I have checked the styles and div's starting and ending myself by so far no success. Am i missing something?
.shell { width:950px; margin:0; position:relative; }
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; }
#main .box { float:left; width:306px; padding:0 19px 0 0; }
#main .shell { padding:25px 0; }
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; }
#footer a { color:#b3adad; text-decoration:none; }
#footer a:hover { text-decoration:underline; }
#footer .footer-navigation { }
#footer .footer-navigation ul { list-style:none; }
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; }
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; }
#footer .footer-navigation ul li a { }
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; }
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; }
#footer .right a:hover { text-decoration:none; }
.box { float:left; width:306px; padding:0 19px 0 0; }
.last-box { padding-right:0; }
.box .entry { height:217px; padding-left:2px; }
.box .big-image { padding:4px 0 10px 0; }
.box .big-image img { border:2px solid #fff; }
.box .buttons .button,
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; }
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; }
<div id="main">
<div class="shell">
<div class="box">
<h2 style="color:#565656;">Latest News</h2>
<div class="entry">
<div class="news">
newsstring;
</div>
</div>
</div>
<div class="box">
</div>
</div>
</div>
<!-- End of Main -->
<!-- Footer -->
<div id="footer">
<div class="shell">
<div class="footer-navigation">
<ul>
<li>Home</li>
<li>About</li>
<li>Gallery</li>
<li>Location</li>
<li class="last">Contact</li>
</ul>
</div>
<div class="container">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px">
<tbody>
<tr>
<td style="height:75px; text-align:center; vertical-align:middle; width:560px">
<p><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Just add "display: inline-block" and "width:100%" in your main div and footer.
CSS:
#footer, #main {
display: inline-block;
width: 100%;
}
Add class .clr to element has class .shell as below:
CSS
.clr:after {
content: "";
display: block;
clear: both;
height: 0;
margin: 0;
padding: 0;
}
HTML
...
<div class="shell clr">
...
Jsfiddle:
https://jsfiddle.net/merLdd2y/
.shell { width:950px; margin:0; position:relative; }
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; }
#main .box { float:left; width:306px; padding:0 19px 0 0; }
#main .shell { padding:25px 0; }
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; }
#footer a { color:#b3adad; text-decoration:none; }
#footer a:hover { text-decoration:underline; }
#footer .footer-navigation { }
#footer .footer-navigation ul { list-style:none; }
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; }
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; }
#footer .footer-navigation ul li a { }
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; }
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; }
#footer .right a:hover { text-decoration:none; }
.box { float:left; width:306px; padding:0 19px 0 0; }
.last-box { padding-right:0; }
.box .entry { height:217px; padding-left:2px; }
.box .big-image { padding:4px 0 10px 0; }
.box .big-image img { border:2px solid #fff; }
.box .buttons .button,
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; }
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; }
<div id="main" style="display:inline; width:100%">
<div class="shell">
<div class="box">
<h2 style="color:#565656;">Latest News</h2>
<div class="entry">
<div class="news">
newsstring;
</div>
</div>
</div>
<div class="box">
</div>
</div>
</div>
<!-- End of Main -->
<!-- Footer -->
<div id="footer">
<div class="shell">
<div class="footer-navigation">
<ul>
<li>Home</li>
<li>About</li>
<li>Gallery</li>
<li>Location</li>
<li class="last">Contact</li>
</ul>
</div>
<div class="container">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px">
<tbody>
<tr>
<td style="height:75px; text-align:center; vertical-align:middle; width:560px">
<p><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
You're not properly clearing your floats.
#footer {
background: url(images/footer.jpg) left top repeat-x;
color: #b3adad;
padding: 24px 4px;
font-size: 10px;
clear: both;
}
This will clear the floats of the header.
You can also create the following class and add that to the parent of any container containing floated elements.
.clearFix:after {display: table; clear: both; content: "";}
An element will float around the next content found in the flow, in this case, footer's text. Check this link for more info about floats: https://css-tricks.com/all-about-floats/
In this case, depending on what you plan for your .shell i would add the following style:
.shell:after {
content: ' ';
display: table;
clear: both;
}
.shell { width:950px; margin:0; position:relative; }
.shell:after {content: ' '; display: table; clear: both;}
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; }
#main .box { float:left; width:306px; padding:0 19px 0 0; }
#main .shell { padding:25px 0; }
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; }
#footer a { color:#b3adad; text-decoration:none; }
#footer a:hover { text-decoration:underline; }
#footer .footer-navigation { }
#footer .footer-navigation ul { list-style:none; }
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; }
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; }
#footer .footer-navigation ul li a { }
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; }
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; }
#footer .right a:hover { text-decoration:none; }
.box { float:left; width:306px; padding:0 19px 0 0; }
.last-box { padding-right:0; }
.box .entry { height:217px; padding-left:2px; }
.box .big-image { padding:4px 0 10px 0; }
.box .big-image img { border:2px solid #fff; }
.box .buttons .button,
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; }
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; }
<div id="main">
<div class="shell">
<div class="box">
<h2 style="color:#565656;">Latest News</h2>
<div class="entry">
<div class="news">
newsstring;
</div>
</div>
</div>
<div class="box">
</div>
</div>
</div>
<!-- End of Main -->
<!-- Footer -->
<div id="footer">
<div class="shell">
<div class="footer-navigation">
<ul>
<li>Home</li>
<li>About</li>
<li>Gallery</li>
<li>Location</li>
<li class="last">Contact</li>
</ul>
</div>
<div class="container">
<table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px">
<tbody>
<tr>
<td style="height:75px; text-align:center; vertical-align:middle; width:560px">
<p><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Keep in mind that there are more solutions. You could use flex-box approach, you could use display:inline-block approach, you coul even use grid approach. It all depends on what you want to achieve and what browsers you want to support.
If you have floated children (.box), your parent block don't know about that until you tell him. Just add to parent block (.shell) style overflow :hidden.
#main .shell { overflow :hidden; }
I have to floated elements in my div, I used clearfix I found in internet, but it isn't working as it should.
<div id="header" class="clear">
<div class="header-left"> </div>
<div class="header-right">
<div class="quick-drop">
<ul>
<li class="quicklinks">Quicklinks
<img src="images/quicklink-icon.png" />
</li>
<li class="dropdown">Select from dropdown
<img src="images/dropdown-icon.png" />
</li>
</ul>
</div>
<div class="search-block">
<input type="text" class="search" name="search" placeholder="Search for something here" />
</div>
</div>
<div class="header-nav">it should be below but it is under</div>
</div>
CSS
.clear:before, .clear:after {
content:"\0020";
display: block;
height: 0;
overflow: hidden;
}
.clear:after {
clear: both;
}
.header-left {
float:left;
margin:40px 0;
}
.header-right {
float:right;
margin:40px 0;
}
.logo {
background:url('../images/logo.png') no-repeat;
width:250px;
height:50px;
display:block;
}
.quick-drop {
display:inline-block;
}
.quick-drop ul {
margin:0;
padding:0;
margin:18px 0;
}
.quick-drop ul li {
list-style-type:none;
display:inline-block;
height:19px;
padding:3px;
text-align:center;
font-size:12pt;
}
ul .quicklinks {
color:#c7c7c7;
border-right:1px #c7c7c7 solid;
}
ul .dropdown {
color:#58159b;
}
.quick-drop ul li img {
margin:0 15px;
}
.search-block {
display:inline-block;
}
.search {
background:url('../images/search-icon.png') right no-repeat #fff;
background-position:260px;
width:260px;
height:16px;
border:none;
outline-color:#58159b;
padding:15px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
color:#c7c7c7;
}
http://jsfiddle.net/qKFAc
The .header-nav should be below the 2 divs, but it is under them, what I'm doing wrong?
Thank you.
Clear fixes should be AFTER the floated elements, like so:
Remove the clear class from the parent. Then:
<!-- Floated -->
<div class="clear"></div>
<div class="header-nav">it should be below but it is under</div>
.header-nav
{
clear:left;
}
please add this css rule
Add this:
.clear {
clear: both;
}
jsFiddle: http://jsfiddle.net/qKFAc/1/
I was wondering if anyone could help me out with a small html/css issue I am having. Basically, I am trying to make a unordered list with a different image for the bullet of each list item, with a text to the right on the same line. More specifically, a header on the top line and some normal text below. At the moment, I can get the image and the text on the same line :-( Here is my code.
Any help would be greatly appreciated.
Html:
<ul>
<li class="service-list">
<img src="image.png" alt="icon" class="alignnone size-full wp-image-156" />
<h3>Header</h3>
<p>
text goes here
</P>
</li>
....
</ul>
CSS:
.service-list {
list-style-type: none;
margin-left:0px;
padding-left:0px;
float: left;
display: inline-block;
}
.service-list p {
text-align: right;
margin: 0;
padding: 0;
}
While using
display:inline-block;
don't use
float:left;
Try
.service-list {
list-style-type: none;
margin-left:0px;
padding-left:0px;
display: inline-block;
}
.service-list img
{
float:left;
}
.service-list p,.service-list h3 {
text-align: right;
display:inline-block;
padding: 0;
}
Here is the Link to Fiddle
I discourage the "tabluar aproach". Tables are for tables. Use <div> instead.
I simply turn the <a> in a block element and wrap the content in a <div> and float both left.
HTML:
<ul id="services-list">
<li>
<a href="http://www.google.com" class="image">
<img src="http://cdn3.iconfinder.com/data/icons/free-social-icons/67/facebook_square-24.png" alt="Facebook Icon" />
</a>
<div class="content">
<h3>Header</h3>
<p>text goes here</p>
</div>
</li>
<li>
<a href="http://www.google.com" class="image">
<img src="http://cdn1.iconfinder.com/data/icons/socialmediaicons_v120/24/facebook.png" alt="Facebook Icon" />
</a>
<div class="content">
<h3>Header</h3>
<p>text goes here</p>
</div>
</li>
</ul>
CSS:
/*a little bit of reset*/
#services-list, #services-list p, #services-list h3 {
list-style: none;
margin:0; padding:0;
}
#services-list > li{
float:left;
margin-right: 20px;
width: 130px;
}
#services-list > li > .image{
display:block;
float:left;
margin-right:10px;
}
/*
this instructions are to force the dimensions of image and its container <a>
*/
#services-list > li > .image,
#services-list > li > .image > img{
width:24px; height:24px;
}
Here's the editable code: http://codepen.io/andreacanton/pen/lykDA
Note: the height of the <ul> will not be proper calculated by the browser because contain floated elements. So you should add some clear:both <div> or force the height of the <ul> element.
.items-list {
box-shadow: -2px 1px 14px #e5e6e8;
list-style-type: none;
margin-left:0px;
padding-left:0px;
margin-bottom:15px;
width:100%;
}
#media only screen and (max-width:400px) {
.items-list {
height:110px;
}
.items-list .kmtext {
padding-bottom:6px;
}
.items-list img
{
float:left;
width:40%;
height:100%;
margin-right:7px;
}
.items-list .righttxt {
width:100%;
padding: 5px;
}
}
#media only screen and (min-width:401px) and (max-width:500px) {
.items-list {
height:200px;
}
.items-list .kmtext {
padding-bottom:20px;
}
.items-list img
{
float:left;
width:45%;
height:100%;
margin-right:7px;
}
.items-list .righttxt {
width:100%;
padding: 15px;
}
}
#media only screen and (min-width:501px) and (max-width:700px) {
.items-list {
height:250px;
}
.items-list .kmtext {
padding-bottom:20px;
}
.items-list img
{
float:left;
width:45%;
height:100%;
margin-right:7px;
}
.items-list .righttxt {
width:100%;
padding: 40px;
}
}
#media only screen and (min-width:701px) and (max-width:1399px) {
.items-list {
height:300px;
}
.items-list .kmtext {
padding-bottom:20px;
}
.items-list img
{
float:left;
width:45%;
height:100%;
margin-right:7px;
}
.items-list .righttxt {
width:100%;
padding: 50px;
}
}
#media only screen and (min-width:1400px) {
.items-list {
height:330px;
}
.items-list .kmtext {
padding-bottom:20px;
}
.items-list img
{
float:left;
width:45%;
height:100%;
margin-right:7px;
}
.items-list .righttxt {
width:100%;
padding: 60px;
}
}
.items-list img
{
object-fit: cover;
border-right: 5px solid;
border-image: linear-gradient(to bottom, #86DF7B 50%,#7BAADF 50%) 2;
}
.items-list .kmtext {
color:#26b7a1;
font-size:80%;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-height: 21px;
max-height: 48px;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
.items-list .pricetext {
color:#020202;
font-weight:bold;
padding-bottom:6px;
font-size:120%;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-height: 21px;
max-height: 48px;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
}
.items-list .titletext {
color:#919396;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
line-height: 21px;
max-height: 48px;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
<ul>
<li class="items-list">
<img src="https://apollo-ireland.akamaized.net/v1/files/rf81eztjcij11-NG/image;s=272x0" alt="icon" width="200" height="auto" />
<div class="righttxt">
<div class="kmtext">
62KM
</div>
<div class="pricetext">
64N
</div>
<div class="titletext">
This is title here
</div>
</div>
</li>
<li class="items-list">
<img src="https://apollo-ireland.akamaized.net/v1/files/rf81eztjcij11-NG/image;s=272x0" alt="icon" width="200" height="auto" />
<div class="righttxt">
<div class="kmtext">
62KM
</div>
<div class="pricetext">
64N
</div>
<div class="titletext">
This is title here
</div>
</div>
</li>
</ul>
This is okay using both media query, you can re-scale it to your likeness