Horizontally aligning images in separate divs in a ul - html

I am trying to align images horizontally but they are all lying on top of each other.
I am pretty new to this so struggling to figure this out!
Any help would be appreciated!
<div class="social">
<ul>
<div class="facebook">
<li></li>
</div>
<div class="twitter">
<li></li>
</div>
<div class="youtube">
<li></li>
</div>
<div class="vimeo">
<li></li>
</div>
</ul>
</div>
Here is the css
.social {
width: 50%;
margin: 0;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
display: inline-block;
position: relative;
}
.social ul {
list-style: none;
margin: 0;
padding: 0;
}
.social ul li {
margin: 0;
padding: 0;
display: inline;
}
.facebook a:link {
background-image: url(../img/facebook.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
position: absolute;
}
.facebook a:hover {
background-position: bottom;
}
.twitter a:link {
background-image: url(../img/twitter.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
position: absolute;
}
.twitter a:hover {
background-position: bottom;
}
.youtube a:link {
background-image: url(../img/youtube.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.youtube a:hover {
background-position: bottom;
}
.vimeo a:link {
background-image: url(../img/vimeo.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.vimeo a:hover {
background-position: bottom;
}
Here is the code in JSFiddle http://jsfiddle.net/hdnrwrmj/

I would suggest to remove the divs and add the class names to the lis and also remove the absolute position. Fiddle
EDIT: Also use inline-block display for lis
HTML
<div class="social">
<ul>
<li class="facebook"></li>
<li class="twitter"></li>
<li class="youtube"></li>
<li class="vimeo"></li>
</ul>
</div>
CSS
.social {
width: 50%;
margin: 0;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
display: inline-block;
position: relative;
}
.social ul {
list-style: none;
margin: 0;
padding: 0;
}
.social ul li {
margin: 0;
padding: 0;
display: inline-block;
}
.facebook a:link {
background-image: url(http://www.cruisedeals.com/images_shared/top-deal-star-35px.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.facebook a:hover {
background-position: bottom;
}
.twitter a:link {
background-image: url(http://upload.wikimedia.org/wikipedia/ca/thumb/a/a0/Logo_upc.png/35px-Logo_upc.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.twitter a:hover {
background-position: bottom;
}
.youtube a:link {
background-image: url(http://data.cyclowiki.org/images/thumb/d/dc/ClericiMariani.png/35px-ClericiMariani.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.youtube a:hover {
background-position: bottom;
}
.vimeo a:link {
background-image: url(http://mkhx.joyme.com/images/mkhx/thumb/8/88/%E5%9C%B0%E7%8B%B1.png/35px-%E5%9C%B0%E7%8B%B1.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.vimeo a:hover {
background-position: bottom;
}

Here is the updated HTML & CSS JSFIDDLE
I have removed div in ul. its not actually as per standards.

Here is the updated fiddle:-
And put your <div> inside the <li>
http://jsfiddle.net/pnsqcL2t/

Related

Anchors are not clickable somehow

I've been trying to make that website for YouTube views and like bot and the logo isn't clickable somehow.
navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
background-color: gray;
}
.navbar ul li {
float: left;
margin-right: 50px;
font-weight: 600;
font-size: 20px;
color: white;
}
li:first-child {
background-image: url(bolbol.png);
width: 150px;
height: 100px;
text-indent: -1400px;
background-size: 100% 100%;
}
li:nth-child(2) {
position: relative;
top: 25px;
}
<div class="navbar">
<ul>
<li>Logo</li>
<li>Liorgay</li>
<li>Nevo King</li>
</ul>
</div>
https://jsfiddle.net/6L3jak0s/
I think what you are trying to do is to make things look like a header, it's better with flexbox. Something like this maybe..
.navbar {
display: flex;
background-color: gray;
margin: 0;
padding: 1rem;
justify-content:space-between;
align-items:center;
}
.navbar ul {
list-style-type: none;
display: flex;
align-items:center;
}
.navbar ul li {
margin-right: 50px;
font-weight: 600;
font-size: 20px;
color: white;
}
li:first-child {
background-image: url(bololo.jpg);
background-size: 100% 100%;
}
.navbar a {
display: block;
}
<div class="navbar">
Logo
<ul>
<li>Liorgay</li>
<li>Nevo King</li>
</ul>
</div>
Remove this property "text-indent: -1400px;" from this rule "li:first-child Rule".
and then add the following CSS.
.navbar li a {
width: 100%;
height: 100%;
display: inline-block;
text-indent: -1400px;
}

My drop down menu wont show even though I put display to block upon hover

The drop-down menu wont work for my navigation. It gets hidden with display:none but upon hovering nothing is shown even though i specified that when the anchor tag containing the UL is hovered over display the child elements as blocked.
html:
<body>
<header id = "M_head">
<h2><ul>MC</ul></h2>
</header>
<div id="container">
<nav id="M_nav">
<ul>
<a>NEWS<img class="Nav_down1" src="Nav_down1.png">
<ul>
<li><a>ting1</a></li>
</ul>
</a>
<a>STORE<img class="Nav_down1" src="Nav_down1.png"></a>
<a>BLOG<img class="Nav_down1" src="Nav_down1.png"></a>
<a>CONTACTS<img class="Nav_down1" src="Nav_down1.png"></a>
<a>ABOUT<img class="Nav_down1" src="Nav_down1.png"></a>
</ul>
</nav>
<section id="M_section">
<div id=Side_sec></div>
<div id="Side_sec2"></div>
</section>
<footer id="M_footer">
</footer>
</div>
</body>
css:
* {
box-sizing: border-box; }
body {
max-width: 100%;
margin: 0px;
display: block; }
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat; }
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em; }
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em; }
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-left: -2.6%;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table; }
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black; }
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none; }
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none; }
#M_nav ul ul {
display: none; }
#M_nav ul > a:hover > ul {
display: block; }
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right; }
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white; }
here is the Jsfiddle link:http://jsfiddle.net/va06bfav/
* {
box-sizing: border-box;
}
body {
max-width: 100%;
margin: 0px;
display: block;
}
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
}
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em;
}
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em;
}
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table;
}
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black;
}
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none;
}
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none;
}
#M_nav ul li {
float: left;
position: relative;
}
#M_nav ul ul {
display: none;
position: absolute;
width: 157px;
top: 34px;
left: 0px;
list-style: none;
}
#M_nav ul a:hover + ul {
display: block;
}
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right;
}
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white;
}
<div id="container">
<nav id="M_nav">
<ul>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
If you see your code in dev tool you can see that Ul which is your drop down menu is not immediate children of your anchor tag it is placed after anchor tag immediately. The selector you are using is X > Y which selects direct children (please see the link for more detailed information about css selector.)
Changes i have made
Changed your markup structure added li in it which was not there earlier and causing the weird behavior of drop down menu which i have mentioned above.
Changed your css selector from X > Y to X X + Y what this selector will do ,It will select only the element that is immediately preceded by the former element.
* {
box-sizing: border-box;
}
body {
max-width: 100%;
margin: 0px;
display: block;
}
#container {
padding: 0;
text-align: center;
box-sizing: border-box;
margin: 0px auto;
margin-top: -.5em;
background-image: url("MircBackground.jpg");
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
}
#M_head {
margin: 0px auto;
color: black;
width: 90%;
background-color: white;
height: 4em;
}
#M_head ul {
padding: 0px auto !important;
margin: 0px;
margin-left: 5em;
text-align: left;
font-style: italic;
font-weight: bold;
width: 30%;
letter-spacing: -0.08em;
word-spacing: -0.03em;
}
#M_nav ul {
width: 102.5%;
padding: 0px;
padding-top: .25em;
padding-bottom: .25em;
margin-left: -2.6%;
margin-top: 0em;
background-color: black;
position: relative;
display: inline-table;
}
#M_nav ul a {
display: inline-block;
list-style-type: none;
text-decoration: none;
text-align: center;
padding-left: 3.5em;
padding-right: 3.5em;
padding-top: 0.35em;
padding-bottom: 0.35em;
display: inline-block;
border-radius: 0.25em;
color: white;
font-weight: bold;
background-color: black;
}
.Nav_down1 {
position: absolute;
height: 0.625em;
margin-left: 0.625em;
margin-top: 0.3125em;
overflow: none;
}
#M_nav ul a:hover {
background-color: #FFBF00;
color: white;
font-shadow: none;
}
#M_nav ul ul {
display: none;
}
#M_nav ul a:hover + ul {
display: block;
}
#Side_sec {
height: 50em;
width: 15%;
border: 2px solid white;
float: right;
}
#M_section {
height: 50em;
width: 80%;
margin: -1em auto;
border: 2px solid white;
}
<div id="container">
<nav id="M_nav">
<ul>
<li>
<a>NEWS<img class="Nav_down1"src="Nav_down1.png">
</a>
<ul>
<li><a>ting1</a></li>
</ul>
</li>
</ul>
</nav>
</div>

image overlapping border in safari

I have a pagination with numbers in circles, when you hover on circle corresponding image will display, but in safari the image is overlapping the circle's border..
Fiddle:-
http://jsfiddle.net/2yx5e3w1/
CSS and HTML
* {
margin: 0;
padding: 0;
}
ul li {
list-style: none;
}
a {
text-decoration: none;
}
.pagination_wrap * {
box-sizing: border-box;
}
.pagination_wrap {
float: left;
width: 680px;
box-sizing: border-box;
position: relative;
}
.pagination_wrap ul {
display: table;
text-align: center;
width: 620px;
margin: auto;
}
.pagination_wrap li {
display: table-cell;
vertical-align: middle;
}
.pagination_wrap li a {
display: block;
width: 51px;
height: 51px;
border-radius: 50%;
border: 2px solid #dadada;
background: #e2e2e2;
margin: auto;
overflow: hidden;
}
.pagination_wrap li a:after {
content: "";
display: inline-block;
height: 100%;
margin-left: -4px;
vertical-align: middle;
width: 0;
}
.pagination_wrap li img {
display: none;
margin-left: -4px;
vertical-align: middle;
}
.pagination_wrap li span {
vertical-align: middle;
display: inline-block;
font-family: Arial, Helvetica, sans-serif;
color: #000;
font-size: 19px;
line-height: 47px;
}
.pagination_wrap li a:hover img, .pagination_wrap li.current img {
display: inline-block;
}
.pagination_wrap li a:hover span, .pagination_wrap li.current span {
display: none;
}
a.prev_arrow, a.next_arrow {
height: 25px;
width: 15px;
background-image: url("http://i9.dainikbhaskar.com/dainikbhaskar2010/images/pagination/slide_nav.jpg");
position: absolute;
}
a.prev_arrow.disabled {
background-position: left -28px;
cursor: default;
}
a.next_arrow.disabled {
background-position: right -28px;
cursor: default;
}
a.prev_arrow {
float: left;
background-position: left top;
left: 0;
top: 12px;
}
a.next_arrow {
float: right;
background-position: right top;
right: 0;
top: 13px;
}
<div class="pagination_wrap">
<ul>
<li class="current"><img src="http://i9.dainikbhaskar.com/thumbnail/51x51/web2images/www.bhaskar.com/2015/04/07/players_1428406480.jpg" alt="" /><span>1</span></li>
<li><span>2</span> <img src="http://i9.dainikbhaskar.com/thumbnail/51x51/web2images/www.bhaskar.com/2015/04/07/players_1428406480.jpg" alt="" /></li>
<li><span>3</span> <img src="http://i9.dainikbhaskar.com/thumbnail/51x51/web2images/www.bhaskar.com/2015/04/07/players_1428406480.jpg" alt="" /></li>
</ul>
</div>
Give a border radius of 100% to both the image and container
.pagination_wrap li a,
.pagination_wrap li a img {
-webkit-border-radius: 100%;
border-radius: 100%;
}
also note that Safari for Windows has been discontinued since May 9, 2012.

CSS responsive menu icon text

I am working on improving my portfolio website (www.kikidesign.net) and am currently working on the footer. I'm trying to make it responsive in which the link (with the icon) will be able to stay the same but will be re-arranged in response to the browser window. For example, for desktop version, it will be in one line, but for tablet version, it will be two lines with two links in each row, and for mobile version, it will be like a list. However, I couldn't keep the icon and text in one place. When I move the browser window around, the icons keep popping out of their place. What should I do to fix it?
HTML
<div id="footercontent">
<ul class="ca-menu">
<li class="about2">
<a href="<?php echo get_option('home'); ?>/about" >
<span class="aboutimg"></span>About Me
</a>
</li>
<li class="contact2">
<a href="<?php echo get_option('home'); ?>/contact" >
<span class="contactimg"></span>Contact
</a>
</li>
<li class="download">
<a href="kikidesignResume.pdf">
<span class="downloadimg"></span>Resume
</a>
</li>
<li class="facebook">
<a href="https://www.facebook.com/kikidesignnet" >
<span class="facebookimg"></span>Facebook
</a>
</li>
</ul>
</div>
CSS
#footercontent {
position: relative;
padding-top: 15px;
margin-left: auto;
margin-right: auto;
width: 100%;
height: 100%;
min-height: 100px;
}
#footercontent .ca-menu {
width: 100%;
padding: 0;
list-style: none;
margin: 30px auto;
}
#footercontent .ca-menu li {
width: 23%;
height: 100%;
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
}
#footercontent .ca-menu li a {
text-decoration: none;
text-align: left;
font-family: 'PrintClearlyRegular';
font-weight: normal;
font-style: normal;
font-size: 1.75em;
}
#footercontent .ca-menu li a:hover {
text-decoration: underline;
text-decoration-color: white;
-moz-text-decoration-color: white;
-webkit-text-decoration-color: white;
-o-text-decoration-color: white;
-ms-text-decoration-color: white;
}
.ca-menu li:hover .aboutimg, .ca-menu li:hover .contactimg, .ca-menu li:hover .downloadimg, .ca-menu li:hover .facebookimg {
color: #ffffff;
/**font-size: 30px;**/
opacity: 1;
}
.aboutimg {
display: inline-block;
width: 50px;
height: 60px;
text-align: center;
background: url(images/girlIcon2.png) no-repeat 0 0;
opacity: 0.3;
vertical-align: middle;
margin-top: -10px;
margin-right: 10px;
}
.ca-menu .about2 a {
color: #f9a145;
border: none;
text-decoration: none;
}
#contactimg {
padding: 15px 0 12px 0;
}
.contactimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/contact.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .contact2 a {
color: #4595d1;
border: none;
text-decoration: none;
padding: 20px;
}
.downloadimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/download.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .download a {
color: #f7e400;
border: none;
text-decoration: none;
padding: 20px;
}
.facebookimg {
display: inline-block;
width: 50px;
height: 60px;
background: url(images/facebook.png) no-repeat 0 0;
margin-left: auto;
margin-right: auto;
vertical-align: middle;
margin-top: -8px;
opacity: 0.3;
margin-right: 10px;
}
.ca-menu .facebook a {
color: #B0B0B0;
border: none;
text-decoration: none;
padding: 20px;
}
#footercontent .ca-menu {
width: 100%;
padding: 0;
list-style: none;
margin: 30px auto;
}
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
}
I have made changes to those two part.
And for mobile:
#media (max-width: 480px) {
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
width: 100%;
}
}
You can do same for other sizes also:
#media (min-width: 480px) and (max-width: 720px) {
#footercontent .ca-menu li {
position: relative;
display: inline-block;
background: #2d1d53;
padding: 0 20px;
float: left;
width: 40%;
}
}
DEMO

HTML,CSS, image position

I don't know how to solve this problem. I have menu with height: 72px and logo with height: 117px. The logo is still with height: 72px. I do responsive design. I can make it with margin positioning, but I think this is not good for responsive.
Picture
Any ideas how to solve it? Thanks a lot
#font-face{font-family: Exo-Bold; src:url(../fonts/Exo-Bold.otf);}
#font-face{font-family: Exo-Light; src:url(../fonts/Exo-Light.otf);}
body
{
background-color: white;
width: 100%;
margin: 0 auto;
}
a
{
text-decoration: none;
}
a:link, a:visited
{
color: white;
}
a:hover, a:active
{
color: white;
text-decoration: underline;
}
.header
{
background-image: url(../images/bg-img.png);
background-repeat: repeat-x;
height: 72px;
width: 100%;
}
.header .nav
{
height: 72px;
margin-left: 15%;
}
.header .nav ul
{
margin: 0 auto;
list-style-type: none;
}
.header .nav ul li
{
float:left;
display: inline-block;
font-family: Exo-Bold;
font-size: 14px;
margin: 25px 20px;
}
.logo
{
background-image:url(../images/logo.png);
background-repeat: no-repeat;
height: 117px;
width: auto;
margin-left: 10%;
}