Arrange text under icons - html

i have a problem with a menu i am making, i want it to be something like:
<icon> <icon> <icon>
Title Longer Title
Title
now i have it like this:
<icon>
<icon> longer <icon>
Title Title Title
I made the menu using lists like this (Copy from actual code)
<ul>
<li>
<img src="images/buton1.png" class="butonmeniu"><h2 class="meniufont" >Info utile</h2>
</li>
</ul>
and the css styles are like this
.meniufont{
font-family:'Open Sans', sans-serif;
font-size:15px;
margin-right:10px;
text-align: center;
font-weight:normal;
color:#434446;
}
.butonmeniu{
display:block;
}
Thanks alot, if you have any questions please ask. Thank you.

li {
display: table-cell;
vertical-align: top;
width: 90px;
padding: 5px;
}
<ul>
<li>
<img src="http://placephant.com/80/80" class="butonmeniu"><h2 class="meniufont" >Info utile</h2>
</li>
<li>
<img src="http://placephant.com/80/80" class="butonmeniu"><h2 class="meniufont" >Info utile Into utile</h2>
</li>
</ul>

Your li are using display:inline-block
Add vertical-align:top to the li as the default there is baseline.
.meniufont {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
font-weight: normal;
color: #434446;
}
.butonmeniu {
display: block;
}
li {
display: inline-block;
text-align: center;
margin: 0 10px;
vertical-align: top;
}
<div class="menu">
<ul>
<li>
<a href="#">
<img src="http://www.fillmurray.com/g/20/20" class="butonmeniu">
<h2 class="meniufont">Title</h2>
</a>
</li>
<li>
<a href="#">
<img src="http://www.fillmurray.com/g/20/20">
<h2 class="meniufont textjos">Longer <br>Title</h2>
</a>
</li>
<li>
<a href="#">
<img src="http://www.fillmurray.com/g/20/20">
<h2 class="meniufont">Title</h2>
</a>
</li>
</ul>
</div>

Sup!
I toyed around with what I thought you were trying to achieve.
See this pen : Codepen Link
#nav { list-style : none;}
.nav-item {
display: inline-block;
width: 100px; /* Make it whatever you want */
}
.meniufont{
font-family:'Open Sans', sans-serif;
font-size:15px;
margin-right:10px;
text-align: center;
font-weight:normal;
color:#434446;
}
.butonmeniu{
display:block;
margin: auto;
width: 100%;
}
<ul id="nav">
<li class="nav-item">
<a href="#">
<img src="http://placehold.it/350x150" class="butonmeniu"><h2 class="meniufont" >Info utile</h2>
</a>
</li>
<li class="nav-item">
<a href="#">
<img src="http://placehold.it/350x150" class="butonmeniu"><h2 class="meniufont" >Info utile</h2>
</a>
</li>
<li class="nav-item">
<a href="#">
<img src="http://placehold.it/350x150" class="butonmeniu"><h2 class="meniufont" >Info utile</h2>
</a>
</li>
</ul>

Related

Responsive Navigation with a nested uls

I'm trying to make my website responsive, but I'm having trouble getting my navigation to work correctly. I've tried adjusting the heights, but it's not aligning.
https://jsfiddle.net/ethacker/hcctkjok/2/
I would like the secondary menu (the one that appears when you hover over a parent menu list item) to be the same height as the "parent" menu (the one that says home, pregnancy, all about baby, etc). I use the PHP file extension, but have just pasted the "header" and "header2" code where it would be if it were all in the single file.
<body>
<header>
<nav>
<h1><a href="index.php"><img src="mommyinfologo.png"/></h1>
<ul class="navMenu">
<a href="index.php">
<li class="parentMenu">Home
<ul class="sub-menu">
<a href="mommymadness.php">
<li>This Mommy's Madness</li>
</a>
<a href="about.php">
<li>About Mommy Info</li>
</a>
<a href="contact.php">
<li>Contact Mommy Info</li>
</a>
</ul>
</li>
</a>
<a href="pregnancysplash.php">
<li class="parentMenu">Pregnancy
<ul class="sub-menu">
<a href="ttc.php">
<li>Trying To Conceive</li>
</a>
<a href="fetaldev.php">
<li>Fetal Development</li>
</a>
<a href="genderpredictions.php">
<li>Gender Predictions</li>
</a>
<a href="labordelivery.php">
<li>Labor and Delivery</li>
</a>
</ul>
</li>
</a>
<a href="aabsplash.php">
<li class="parentMenu">All About Baby
<ul class="sub-menu">
<a href="advice.php">
<li>Advice</li>
</a>
<a href="guidelines.php">
<li>Guidelines</li>
</a>
<a href="milestones.php">
<li>Milestones</li>
</a>
<a href="learndev.php">
<li>Learning Development</li>
</a>
</ul>
</li>
</a>
<a href="healthsplash.php">
<li class="parentMenu">Health
<ul class="sub-menu">
<a href="pregnutrition.php">
<li>Pregnancy Nutrition</li>
</a>
<a href="breastfeeding.php">
<li>Breastfeeding</li>
</a>
<a href="formula.php">
<li>Formula Feeding</li>
</a>
<a href="toddlers.php">
<li>Toddler Nutrition</li>
</a>
<a href="preexercise.php">
<li>Prenatal Exercise</li>
</a>
<a href="postexercise.php">
<li>Postpartum Exercise</li>
</a>
<a href="organic.php">
<li>Organic DIY Health</li>
</a>
</ul>
</li>
</a>
<a href="partymommasplash.php">
<li class="parentMenu">Party Momma
<ul class="sub-menu">
<a href="pregann.php">
<li>Pregnancy Announcement</li>
</a>
<a href="genderreveal.php">
<li>Gender Reveal</li>
</a>
<a href="babyshower.php">
<li>Baby Shower</li>
</a>
<a href="birthann.php">
<li>Birth Announcement</li>
</a>
<a href="birthdays.php">
<li>Birthdays</li>
</a>
</ul>
</li>
</a>
<a href="stationssplash.php">
<li class="parentMenu">Stations
<ul class="sub-menu">
<a href="hospitalbag.php">
<li>Hospital Bag</li>
</a>
<a href="diaperbag.php">
<li>Diaper Bag</li>
</a>
<a href="changingstation.php">
<li>Changing Station</li>
</a>
<a href="babygear.php">
<li>Baby Gear</li>
</a>
</ul>
</li>
</a>
<a href="memorymarkerssplash.php">
<li class="parentMenu">Memory Markers
<ul class="sub-menu">
<a href="diymemories.php">
<li>Do It Yourself</li>
</a>
<a href="purchasable.php">
<li>Buy It</li>
</a>
</ul>
</li>
</a>
<a href="reviewsplash.php">
<li class="parentMenu">Reviews
<ul class="sub-menu">
<a href="games.php">
<li>Games</li>
</a>
<a href="gear.php">
<li>Gear</li>
</a>
<a href="learning.php">
<li>Learning</li>
</a>
</ul>
</li>
</a>
<a href="mommymadness.php">
<li class="parentMenu">Blog
</li>
</a>
</ul>
<?php include_once ("header2.php"); ?>
</nav>
</header>
<!-- Header2.php -->
<div id="handle">
<p>☰Menu</p>
<ul id="navSmall">
<li class="parentMenuSmall">Home
<ul class="sub-menu-small">
<a href="index.php">
<li>Home</li>
</a>
<a href="about.php">
<li>About</li>
</a>
<a href="contact.php">
<li>Contact</li>
</a>
<a href="mommymadness.php">
<li>Mommy Madness</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Pregnancy
<ul class="sub-menu-small">
<a href="pregnancysplash.php">
<li>Pregnancy</li>
</a>
<a href="ttc.php">
<li>Trying to Conceive</li>
</a>
<a href="fetaldev.php">
<li>Fetal Development</li>
</a>
<a href="genderpredictions.php">
<li>Gender Predictions</li>
</a>
<a href="labordelivery.php">
<li>Labor and Delivery</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">All About Baby
<ul class="sub-menu-small">
<a href="aabsplash.php">
<li>All About Baby</li>
</a>
<a href="advice.php">
<li>Advice</li>
</a>
<a href="guidelines.php">
<li>Guidelines</li>
</a>
<a href="milestones.php">
<li>Milestones</li>
</a>
<a href="learndev.php">
<li>Learning Development</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Health
<ul class="sub-menu-small">
<a href="healthsplash.php">
<li>Health and Nutrition</li>
</a>
<a href="pregnutrition.php">
<li>Pregnancy Nutrition</li>
</a>
<a href="breastfeeding.php">
<li>Breastfeeding</li>
</a>
<a href="mommymadness.php">
<li>Formula Feeding</li>
</a>
<a href="toddlers.php">
<li>Toddler Nutrition</li>
</a>
<a href="preexercise.php">
<li>Prenatal Exercise</li>
</a>
<a href="postexercise.php">
<li>Postpartum Exercise</li>
</a>
<a href="organic.php">
<li>Organic DIY Health</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Party Momma
<ul class="sub-menu-small">
<a href="partymommasplash.php">
<li>Party Momma</li>
</a>
<a href="pregann.php">
<li>Pregnancy Announcement</li>
</a>
<a href="genderreveal.php">
<li>Gender Reveal</li>
</a>
<a href="babyshower.php">
<li>Baby Shower</li>
</a>
<a href="birthann.php">
<li>Birth Announcement</li>
</a>
<a href="birthdays.php">
<li>Birthdays</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Stations
<ul class="sub-menu-small">
<a href="stationssplash.php">
<li>Stations</li>
</a>
<a href="hospitalbag.php">
<li>Hospital Bag</li>
</a>
<a href="diaperbag.php">
<li>Diaper Bag</li>
</a>
<a href="changingstation.php">
<li>Changing Station</li>
</a>
<a href="babygear.php">
<li>Baby Gear</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Memory Markers
<ul class="sub-menu-small">
<a href="index.php">
<li>Memory Markers</li>
</a>
<a href="diymemories.php">
<li>Do It Yourself</li>
</a>
<a href="purchasable.php">
<li>Buy It</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Reviews
<ul class="sub-menu-small">
<a href="reviewsplash.php">
<li>Reviews</li>
</a>
<a href="games.php">
<li>Games</li>
</a>
<a href="gear.php">
<li>Gear</li>
</a>
<a href="learning.php">
<li>Learning</li>
</a>
</ul>
</li>
<li class="parentMenuSmall">Blog
<ul class="sub-menu-small">
<a href="mommymadness.php">
<li>This Mommy's Madness</li>
</a>
</ul>
</li>
</ul>
</div>
<section class="section" id="home">
<h2>Welcome to Mommy Info</h2>
<div>
Whether you've been there and done that, or you're coming in for your first stop, this is the site for you.
<p>
Visit the Pregnancy page to access all kinds of information relating to carrying your little one.
<br> Visit the All About Baby page to see all sorts of facts about how the baby is growing, advice about raising him or her, and how to encourage healthy development.
<br> Looking for help deciding how to feed your little one or how to stay fit, visit the Health page!
<br> Maybe you're looking for ideas to celebrate milestones in your baby's life, check out the Party Momma or Memory Markers tabs!
<br> Stressed about what to get for your baby? Visit the Stations or Reviews tabs!
<br> Finally, if you're just wanting to take a gander at the madness that is my life, visit my blog!
</p>
</div>
</section>
<aside class="section" id="about">
<h2>You're on the Home Page!</h2>
<ul class="nav">
<li>The Mommy Behind the Madness</li>
<li>About Mommy Info</li>
<li>Contact Mommy Info</li>
</ul>
<div class="hide" id="blogposts">
<h2>Recent Madness</h2>
<p>Five Months, and What Have I Done?!</p>
<p>Four Months, and What Do I Need?</p>
<p>Three Months, and Help! What's Happening!?</p>
<p>Two Months</p>
<p>It's Positive!</p>
</div>
</aside>
<script async defer src="//assets.pinterest.com/js/pinit.js"></script>
</body>
CSS
body {
color:#ADD8E6;
background-image:url(backgroundarrows.png);
font-family:"Monotype Corsiva", sans-serif;
margin:0;
padding:0;
}
/* Global */
ul{
list-style-type: none;
margin: 0;
padding: 0;
}
a{
text-decoration: none;
color:#737597;
;
}
.section {
background-color:#fafbff;
border:thin solid #D3D3D3;
border-radius:10px;
box-shadow:lightgray 5px 5px 5px;
color:#696969;
display:inline;
float:left;
width:60%;
margin:0 1% 1%;
padding:5px 8px;
}
.section h2 {
border-bottom:solid medium #90cdd0;
color:#90cdd0;
text-align:center;
}
#about {
color:dimgrey;
float:right;
font-size:medium;
margin:1% 1% 0;
text-align:center;
width:33%;
}
.nav li {
text-align:left;
font-size:large;
padding:1%;
}
.nav a {
text-decoration:none;
color:darkgrey;
}
#home {
margin:1% 0 1% 1%;
}
#home div {
font-size:20px;
line-height:30px;
padding:1% 3%;
text-align:center;
}
#home div p{
font-family:"Times New Roman", serif;
font-size:20px;
line-height: 30px;
text-align:left;
}
.hide {
display: none;
}
/* Header */
header {
background-color:#cff1ff;
height:60px;
padding:5px 0;
}
header h1 {
color:#809dc6;
display:inline;
font-family:"Monotype Corsiva", sans-serif;
font-size:45px;
height:50px;
padding:5px 15px;
}
/*Website Navigation */
.navMenu {
display:inline;
font-size:20px;
}
.navMenu .parentMenu {
background-color:#cff1ff;
display:inline-block;
padding:5px 10px;
position:relative;
z-index:100000;
}
.navMenu .parentMenu:hover{
background-color:#bfd3ee;
}
.navMenu .parentMenu a{
color:#737597;
}
.navMenu .parentMenu:hover a:hover{
color:#87a2be;
}
.navMenu .parentMenu .sub-menu{
display:none;
left:0;
padding:0;
position:absolute;
top:33px;
width:180px;
z-index:10000;
}
.navMenu .parentMenu:hover .sub-menu{
display:block;
white-space:nowrap;
}
.navMenu .parentMenu:hover .sub-menu li{
background-color:#bfd3ee;
font-size:17px;
padding:10px;
text-align:left;
white-space:nowrap;
width:100%;
z-index:10000;
}
.navMenu .parentMenu .sub-menu li:hover{
background-color:#9ac9ed;
}
#handle{
font-size: 20px;
display: none;
color: #87a2be;
float: left;
width: 100%;
text-align: left;
}
#navSmall {
display: none;
text-align: center;
background-color: #cff1ff;
height: 100%;
}
#handle:hover #navSmall {
display: inline;
}
.sub-menu-small{
display: none;
background-color: #9ac9ed;
position: relative;
}
.sub-menu-small li {
border-bottom: solid thin #809dc6;
padding:1px 3px;
}
#navSmall .parentMenuSmall {
background-color: inherit;
text-align: left;
padding: 15px;
border-bottom: solid thin #809dc6;
font-size: 18px;
}
#navSmall .parentMenuSmall:hover .sub-menu-small {
display: inline-block;
margin-left: 100px;
position: absolute;
}
#construct {
width: 100%;
height: 100%;
margin-top: 100px;
border-radius: 20%;
}
/* Media Queries */
/*tablet*/
/*remove floats */
#media(max-width: 768px) {
body{
width: 100%;
}
header {
float: none;
text-align: center;
width: 100%;
height: 120px;
}
.section{
width: 95%;
}
#about{
display: none;
}
#handle{
display: block;
}
.navMenu {
display: none;
}
}
/* Tables on Diaper Bag*/
table {
width: 100%;
text-align: center;
}
table th {
font-size: 28px;
}
table td {
font-size: 15px;
font-family: "Comic Sans MS", sans-serif;
font-weight: bold;
}
#main {
color: #66CDAA;
}
#quick {
color: #809dc6;
}
#car {
color: #95b6c0;
}
#item, .item {
color: #9c9c9c;
}
.mainBag {
background-color: rgba(102, 205, 170, 0.1);
}
.toiletries {
background-color: rgba(128, 157, 198, 0.1);
}
.firstAid {
background-color: rgba(149, 182, 192, 0.1);
}
table td {
border: solid thin gray;
border-top:none;
border-right: none;
}
.right {
background-color: palegreen;
}
.wrong {
background-color: #ffc5b7;
}
.girl {
background-color: lightpink;
}
.boy {
background-color: lightblue;
}
.section p {
font-family: "Times New Roman", serif;
}
.items {
font-size: 20px;
font-family: "Times New Roman", serif;
color: #95b6c0;
}
.itemDesc{
font-size: 18px;
color: #6b6b6b;
}

align center a UL with only images [duplicate]

This question already has answers here:
How to align a <div> to the middle (horizontally/width) of the page [duplicate]
(27 answers)
Closed 6 years ago.
I have a <ul> with 6 images, no text. I can't seem to make it be in the center of the page. This is my code.
CSS
.logos{
margin:0 auto;
text-align:center;
display:table;
float: left;
}
HTML
<div class="logos" style="margin:0 auto;">
<ul class="logos">
<li class="logos"> <img src="imgs/logo1.gif"> </li>
<li class="logos"> <img src="imgs/logo2.gif"> </li>
<li class="logos"> <img src="imgs/logo3.gif"> </li>
<li class="logos"> <img src="imgs/logo4.gif"> </li>
<li class="logos"> <img src="imgs/logo5.gif"> </li>
<li class="logos"> <img src="imgs/logo6.gif"> </li>
</ul>
</div>
You need to change
.logos{
margin:0 auto;
text-align:center;
display:table;
float: left;
}
to
.logos{
margin:0 auto;
text-align:center;
display:table;
}
and the content will be in the middle of the page
Also you need to delete the div because is useless ,you set the same class to the ul and to div
Do it like this
.logo_wrapper {
width: 100%;
position: relative;
}
.logos {
position: absolute;
left: 50%;
transform: translateX(-50%);
padding: 0;
}
.logo {
display: inline-block;
margin: 0 auto;
text-align: center;
float: left;
}
<div class="logo_wrapper">
<ul class="logos">
<li class="logo">
<img src="imgs/logo1.gif">
</li>
<li class="logo">
<img src="imgs/logo2.gif">
</li>
<li class="logo">
<img src="imgs/logo3.gif">
</li>
<li class="logo">
<img src="imgs/logo4.gif">
</li>
<li class="logo">
<img src="imgs/logo5.gif">
</li>
<li class="logo">
<img src="imgs/logo6.gif">
</li>
</ul>
</div>
First of all remove the class name for div. ul and div have the same class name.
Give float:left to li
.logos{
margin:0 auto;
display:table;
}
.logos li{
float:left;
}
<div>
<ul class="logos">
<li class="logos"> <img src="imgs/logo1.gif"> </li>
<li class="logos"> <img src="imgs/logo2.gif"> </li>
<li class="logos"> <img src="imgs/logo3.gif"> </li>
<li class="logos"> <img src="imgs/logo4.gif"> </li>
<li class="logos"> <img src="imgs/logo5.gif"> </li>
<li class="logos"> <img src="imgs/logo6.gif"> </li>
</ul>
</div>

Remove gap to the right of a list

I am trying to make a web page that looks similar to a mobile phones home page. I would like it to reorder the icons depending on the size of the screen.
what I have so far is bellow
ul {
list-style: none;
padding: 0;
}
li {
display: inline-block;
width: 5em;
height: 5em;
padding: 1em;
margin: 1em;
background-color: rgba(20, 20, 20, 0.7);
border-radius: 1em;
}
img {
width: 100%;
height: 100%;
}
<ul>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
</ul>
The problem with this code is that when you resize the window and the list items move to the next line, you can be left with a big gap on the right hand side. Is there a way I can distribute this extra space either by centering the list as whole or between the list items? I would like to avoid centering the icons so I can keep them all aligned both horizontally and vertically.
I change from inline-block to float:left and i move your padding to img
ul {
list-style: none;
padding: 0;
animation: FadeIn 1.3s;
width: 100%;
}
li {
float: left;
background-color: rgba(20, 20, 20, 0.7);
border-radius: 1em;
width: 13.42%;
}
ul li:not(:first-child){
margin-left: 1%;
}
img {
width: 82%;
padding: 8%;
}
<ul>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
</ul>
I just copied your code and added media queries. I hope this would help.
CSS Added:
#media only screen and (max-width: 768px) {
ul {
padding: 10%;
}
}
ul {
list-style: none;
padding: 0;
animation: FadeIn 1.3s;
}
li {
display: inline-block;
width: 5em;
height: 5em;
padding: 1em;
margin: 1em;
background-color: rgba(20, 20, 20, 0.7);
border-radius: 1em;
}
img {
width: 100%;
height: 100%;
}
#media only screen and (max-width: 768px) {
ul {
padding: 10%;
margin-top: 0;
}
}
<ul>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
<li>
<a href="http://www.google.com">
<img class=link src="https://www.google.com.au/images/branding/googleg/1x/googleg_standard_color_128dp.png">
</a>
</li>
</ul>

Having a background without moving the letter's position

I want to add a button background to the "a" without moving its position.
The table B is almost correct except that you move the "a" the right side.
I don't know how to do it.
You also need to take account to the I also need to change the size of the width in the future.
Thanks!
#testtesttesttest {
width: 50px;
background-color: #F1F2F2;
-webkit-border-radius: 20px;
border-width: 1px;
border-color: #47a417;
text-decoration: none;
text-align: center;
padding: 1px 8px;
display: inline-block;
line-height: 21px;
color: white;
font-family: Helvetica,Arial,sans-serif;
}
#testtesttesttest:hover {
background-color: #3D8E14;
}
ul.aa, ul.bb
{
list-style-type: none;
}
Table A:
<ul class="aa">
<li>
<a href="#">
a
</a>
</li>
<li>
<a href="#">
b
</a>
</li>
<li>
<a href="#">
c
</a>
</li>
<li>
<a href="#">
d
</a>
</li>
<li>
<a href="#">
e
</a>
</li>
</ul>
<br/>
<br/>
Table B:
<ul class="bb">
<li>
<a href="#">
<span id="testtesttesttest">a</span>
</a>
</li>
<li>
<a href="#">
b
</a>
</li>
<li>
<a href="#">
c
</a>
</li>
<li>
<a href="#">
d
</a>
</li>
<li>
<a href="#">
e
</a>
</li>
</ul>
Try to give negative left margin
#testtesttesttest {
width: 50px;
background-color: #F1F2F2;
-webkit-border-radius: 20px;
border-width: 1px;
border-color: #47a417;
text-decoration: none;
text-align: center;
padding: 1px 8px;
display: inline-block;
line-height: 21px;
color: white;
font-family: Helvetica,Arial,sans-serif;
margin-left:-30px;
}
#testtesttesttest:hover {
background-color: #3D8E14;
}
ul.aa, ul.bb
{
list-style-type: none;
}
Table A:
<ul class="aa">
<li>
<a href="#">
a
</a>
</li>
<li>
<a href="#">
b
</a>
</li>
<li>
<a href="#">
c
</a>
</li>
<li>
<a href="#">
d
</a>
</li>
<li>
<a href="#">
e
</a>
</li>
</ul>
<br/>
<br/>
Table B:
<ul class="bb">
<li>
<a href="#">
<span id="testtesttesttest">a</span>
</a>
</li>
<li>
<a href="#">
b
</a>
</li>
<li>
<a href="#">
c
</a>
</li>
<li>
<a href="#">
d
</a>
</li>
<li>
<a href="#">
e
</a>
</li>
</ul>
Setting the span to inline-block doesn't help so change that to inline. Then remove the 8px padding and you're done.
If you want the text to remain in the same place but also keep it centered inside the background, you could shift it back with a CSS transform (equal to width/2 - horizontal padding/2):
#testtesttesttest {
transform: translateX(calc(-50% + 4px));
}
Here's a JSFiddle to show the effect. Try changing around the width, and you'll see the text still stays in the same place. Hope this helps! Let me know if you have any questions.

HTML/CSS Items are placed under eachother - Need to be scrollable

I have a box with items which are working fine with a couple of items, but if it exceed x amount of items the next item goes under the other - Screenshot.
The 8th item need to go beside the 7th and then the box needs to be scrollable.
Code:
<ul class="items">
<div class="box">
<li>
<a href="#">
<img src="https://steamcommunity-a.akamaihd.net/economy/image/class/730/1026951730/128fx100f">
<h5>Test</h5>
<p class="price">$25.00</p>
</a>
</li>
<li>
<a href="#">
<img src="https://steamcommunity-a.akamaihd.net/economy/image/class/730/1026951730/128fx100f">
<h5>Test</h5>
<p class="price">$25.00</p>
</a>
</li>
<li>
<a href="#">
<img src="https://steamcommunity-a.akamaihd.net/economy/image/class/730/1026951730/128fx100f">
<h5>Test</h5>
<p class="price">$25.00</p>
</a>
</li>
<li>
<a href="#">
<img src="https://steamcommunity-a.akamaihd.net/economy/image/class/730/1026951730/128fx100f">
<h5>Test</h5>
<p class="price">$25.00</p>
</a>
</li>
<li>
<a href="#">
<img src="https://steamcommunity-a.akamaihd.net/economy/image/class/730/1026951730/128fx100f">
<h5>Test</h5>
<p class="price">$25.00</p>
</a>
</li>
<li>
<a href="#">
<img src="https://steamcommunity-a.akamaihd.net/economy/image/class/730/1026951730/128fx100f">
<h5>Test</h5>
<p class="price">$25.00</p>
</a>
</li>
<li>
<a href="#">
<img src="https://steamcommunity-a.akamaihd.net/economy/image/class/730/1026951730/128fx100f">
<h5>Test</h5>
<p class="price">$25.00</p>
</a>
</li>
<li>
<a href="#">
<img src="https://steamcommunity-a.akamaihd.net/economy/image/class/730/1026951730/128fx100f">
<h5>Test</h5>
<p class="price">$25.00</p>
</a>
</li>
</div>
</ul>
CSS:
ul.items li {
width: 150px;
display: inline-block;
vertical-align: top;
*display: inline;
}
p.price {
color: #A65353;
}
box {
background: #fff;
border: 1px solid #dbdbdb;
padding-bottom: 5px;
margin-top: 5px
}
SOLUTION:
box {
background: #fff;
border: 1px solid #dbdbdb;
padding-bottom: 5px;
margin-top: 5px;
white-space: nowrap;
overflow-x: scroll
}
set like this
CSS
ul.items li {
width: 150px;
display: inline-block;
vertical-align: top;
*display: inline;
}
p.price {
color: #A65353;
}
box {
background: #fff;
border: 1px solid #dbdbdb;
padding-bottom: 5px;
margin-top: 5px;
// add this styles
white-space:no-wrap;
overflow-x:scroll;
}