I was toying with some made code on codepen, trying to get used to html/css since I am not really comfortable on the positioning. This must be pretty silly but I can't make it work.
HTML:
<div id="hh">
<h1>Wacom Hover Effect</h1>
</div>
<div id="cl">
Read More
Learn More
Read Article
Download
</div>
CSS:
*, :before, :after{ #include box-sizing('border-box'); }
body{ padding: 1em; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background: #eee; }
#hh{
position:absolute;
left:50%
}
h1{
position:relative;
left:-50%;
font: 300 3em/1em 'Open Sans', sans-serif;
border: solid 0.00019em #000;
margin-bottom: 0.2em;
padding: 0.4em 0.2em 0.4em 0.2em;
background-color:lightblue;
border-radius:0.2em;
}
#cl{
clear:both;
}
.button,
[class*="button-"]{
position: relative;
display: inline-block;
overflow: hidden;
float:left;
margin: 0 1em 1em 0;
padding: 0 4em;
height: 3.5em;
font: 300 1em/3.5em 'Open Sans', sans-serif;
text:{
decoration: none;
shadow: 0 1px 3px rgba(black, .35);
}
letter-spacing: .08em;
color: #fff;
background: #0090C0;
border: solid 1px #fff;
border-radius: 2px;
#include transition(.35s ease all);
}
}
There is some irrelevant code after that about hovering etc.
The result is this: http://codepen.io/roygbiv/full/FjLcA
So I wanted h1 at center and I found here the method of putting #hh absolute, left:50% and then h1 relative left:-50%. And it screwed up the positioning.
What I want is h1 on center top, then the 4 "a"s under it (not center, just not overlapping).
Putting position: absolute on an element makes all other elements ignore it. This can be solved by putting display: inline-block on the h1 and text-align: center on #hh:
Check new pen: http://codepen.io/anon/pen/kovaC
#hh {
text-align: center;
}
h1{
font: 300 3em/1em 'Open Sans', sans-serif;
border: solid 0.00019em #000;
margin-bottom: 0.2em;
padding: 0.4em 0.2em 0.4em 0.2em;
background-color:lightblue;
border-radius:0.2em;
display: inline-block;
}
inline-block makes the element's box adapt to the width of its text. I presume the desired look of the header is for the blue box to not be 100% width, which is otherwise the case with h1 and other block elements.
i have done the following modification in css and it is working as expected:
#hh{
text-align: center;
margin-left:auto;
margin-right:auto;
width:40%;
}
h1{
font: 300 3em/1em 'Open Sans', sans-serif;
border: solid 0.00019em #000;
margin-bottom: 0.2em;
padding: 0.4em 0.2em 0.4em 0.2em;
background-color:lightblue;
border-radius:0.2em;
}
Related
I've got the following:
HTML:
<div class="boxy"><img><p>Paragraph testing.</p></div>
CSS:
.boxy{
width= 150px;
background: #E5E5E5;
filter:alpha(opacity=90);
opacity:0.9;
color: #e9e9e9;
font-family: "Century Gothic", arial, sans-serif;
border-radius: 8px;
font-size: 12px;
font-weight: bold;
padding: 2px 2px 2px 5px;
margin:0 auto;
overflow: visible;
}
I notice that on jsfiddle the div appears long although I've limited it by width. I've also added Overflow:Visible but did not work. Would appreciate any advise. Thanks!
Change:
width= 150px;
To this:
width: 150px;
I am trying to code this block of text with image in it but for some reason it's not working for me as. What would be the best approach to get this right with CSS?
Thank you all!
UPDATE
This is what I got the problem is with that the underline heading
http://jsfiddle.net/C2kqR/
.block h3{
margin-bottom: 0.6em;
margin-top: 0;
color: #c80006;
font-weight: 400;
font-style: normal;
font-size: 22px;
line-height: 1.2em;
font-family: 'Signika', sans-serif;
text-rendering: optimizeLegibility;
}
.heading {
margin-bottom: 20px;
color: #c80006
}
.aleft {
float:left;
margin:0 2em 0 0 !important;
}
.hr-line-full {
width: 100%;
margin: 22px 0 35px;
display: block;
border-top: 1px solid #dedede
}
Have a look at this fiddle
CSS:
img{
float:left;
margin:0 10px 10px 0;
}
As long as the text and image are within a parent container, simply float the image left to have the text wrap around it. To Space it apart from the text, give it a margin and voila!
I have a solution for you where you can remove the hr element you are trying to imitate and instead use border for the h3.
Changed CSS for .heading:
.heading {
margin-bottom: 34px;
padding-bottom: 24px;
color: #c80006;
border-bottom: 1px solid #dedede;
overflow: hidden;
}
Fiddle here
I'm new to css, I have a top nav but I couldn't set its width. It seems different when I test with Dreamweaver, ie9, ie6, Firefox and Opera. Here's my code:
#charset "utf-8";
/* CSS Document */
html {
background: url(images/light-tile.gif) repeat;
}
body {
overflow: auto;
width: 54.35em;
margin: 0 auto;
background-color: #fff;
padding-left: 0.25em;
padding-right: 0.4em;
border: 0.07em solid #97b4e0;
overflow: visible;
}
#main {
background-color: #fff;
}
ul#top-nav {
list-style: none;
margin: .9em .9em .9em 0;
padding: 0;
width: 110%;
}
ul#top-nav li {
display: inline;
}
ul#top-nav li a {
text-decoration: none;
font-size: 0.75em;
font-family: Arial, Helvetica, sans-serif;
padding: 0.90em 0;
width: 18.5%; /* for 5 items */
background: #99CCFF;
color: #3F4037;
font-weight: bold;
float: left;
display: inline-block;
text-align: center;
border-right: 0.05em solid #fff;
border-left: 0.05em solid #fff;
border-bottom: 0.2em solid #97b4e0;
}
ul#top-nav li a:hover {
color: #000;
font-weight: bolder;
background: #D7EBFF;
border-bottom: 0.2em solid #e9e9e9;
}
...
<body>
<div id="main">
<div id="top-info">Kumcuğaz Köyü İlköğretim Okulu</div>
<img id="top-image" src="../images/top_image.png" alt="üst resim" width="869" height="159" />
<ul id="top-nav">
<li>ANASAYFA</li>
<li>GALERİ</li>
<li>PERSONEL</li>
<li>İLETİŞİM</li>
<li>ZİYARETÇİ DEFTERİ</li>
</ul>
<div class="clear"></div>
<div id="faux">
...
If it isn't possible it to view same on all browsers, I'll have to use a table. Thanks for helping.
Sincerely
What's the reason for making it 110% wide? That's wider than the window. Also, you have 5 menu items each set to 18.5% wide... that adds up to only 90.5% total.
What happens when you make it 100% wide and each of the 5 items is 20% wide?
http://jsfiddle.net/u78Ks/2/
It looks like this might be the issue
width: 18.5%; /* for 5 items */
in here
ul#top-nav li a {
text-decoration: none;
font-size: 0.75em;
font-family: Arial, Helvetica, sans-serif;
padding: 0.90em 0;
width: 18.5%; /* for 5 items */
background: #99CCFF;
color: #3F4037;
font-weight: bold;
float: left;
display: inline-block;
text-align: center;
border-right: 0.05em solid #fff;
border-left: 0.05em solid #fff;
border-bottom: 0.2em solid #97b4e0;
}
Browsers could be interpreting this differently based on the font sizes, window sizes, etc.
Try setting this to a static width in pixels.
I've been working on this for a while and can't seem to solve the problem myself or find an answer anywhere.
Basically whats happening is, I have a vertical Navigation bar all the way to the left of my image so instead of the image being centered from the completely left side of the browser window to the right side, It gets centered from the right side of the navigation bar to the right side of the browser window. This throws it off with my title "desertshore" and my page content, which are both actually centered.
Is there a way that I can make it see pass the Nav bar and center itself around the browser window?
here is the code:
<html>
<head>
<title>dir</title>
<style type="text/css">
body {
font-family: "Arial", "Helvetica", "Helvetica Neue";
font-size: 14px;
background-image: url('.jpg');
background-position:center;
background-size:50em;
background-repeat:no-repeat;
margin: 30px 0px 0 0;
text-align: left;
color: #333;
}
title {
font-family: "Arial", "Helvetica", "Helvetica Neue";
font-size: 14px;
background-image: url('.jpg');
background-position:center;
background-size:50em;
background-repeat:no-repeat;
margin: 30px 0px 0 0;
text-align: left;
color: #333;
}
div#container {
width:100px;
background:#FFF;
height:auto;
overflow:auto;
border: 1px solid black;
border-left:0;
float:left;
}
div#site_title {
color:#00ffff;
text-transform: lowercase;
font-weight: ;
font-size: 35px;
line-height: 15px;
margin: 0 0 0 0px;
}
div#site_title2 {
color:#00ffff;
text-transform: uppercase;
font-weight: bold;
font-size: 17px;
line-height: 15px;
margin: 0 0 0 0px;
}
#menu ul{
list-style-type: none;
padding: 0;
margin-left: 0;
}
div#menu li a
{
background:#fff
border:1px solid #fff;
margin: 0;
padding: 0;
display: block;
}
-googlechromefix-
div#menu li:hover a {
background:#00ffff;
color:#FFFFFF;
border:1px solid #fff;
margin: 0;
padding: 0;
display: block;
}
div#menu ul a
{
text-decoration: none;
color: #333;
}
div#menu ul a:hover
{
background:#00ffff;
color:#FFFFFF;
font-weight:bold
}
div#page_content {
font-family: "Arial", "Helvetica", "Helvetica Neue";
font-size: 14px;
margin: 30px 0px 0 0;
text-align: left;
color: #333;
}
.color01 {
color:
}
#desertshoredom2 {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
border: 1px solid red;
}
div#container2 {
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
</head>
<body>
<div id="site_title">
<center><span> △▲desertshore▲△</span></center>
<div id="site_title2">
<span>directory</span>
</div>
</div>
<div id="container">
<div id="menu">
<ul>
<li><span class="color01">Happy Anniversary</span> </li>
<p><li><span class="color01">Downloads</span></li </p>
<p><li><span class="color01">About</span></li></p>
<p><li><span class="color01">Ask</span></li></p>
</ul>
</div>
</div>
<p><img id="desertshoredom2" src="desertshoredom2.jpg"/></p>
<div id="container2">
<h1>+++test+++ Test +++test+++</h1>
<p> idreamed idreamed</p>
</div>
</body>
Thanks a lot for helping me, This seems like something really simple that I'm not doing, however my experience in HTML/CSS is extremely elementary.
You just need to update the following CSS Block to add position:absolute;
DEMO: http://jsfiddle.net/Jaybles/pzuRp/
div#container {
width:100px;
background:#FFF;
height:auto;
overflow:auto;
border: 1px solid black;
border-left:0;
float:left;
position:absolute;
}
I'm making some tabs, using a background image as the hover state background. The only one that looks fine is "Day". I presume, because it's only 3 characters and the other tabs are 4 characters. Is there a way to make it so the hover background is centered on all of them? Here is the css for the list.
li {
font: 9pt "Helvetica Neue", Helvetica, Arial, "Trebuchet MS", Trebuchet, serif;
margin-top: .192333333em;
float: right;
height: 19px;
width: 40px;
margin-left: 10px;
display: inline-block;
margin: 7px;
}
li.current {
background: url('img/red-current-bg.png') no-repeat;
line-height: 1.6em;
}
ul#tabnav {
margin: 0;
}
ul#tabnav li a {
text-shadow: 0 1px #800000;
text-decoration: none;
padding: 8px 11px;
line-height: 1.6em;
}
ul#tabnav li:hover {
background: url('img/red-current-bg.png') 0 0 no-repeat;
}
Can you just adjust the horizontal position of the background to adjust the pixels or center the image?
ul#tabnav li:hover {
background: url('img/red-current-bg.png') 3px 0 no-repeat;
}
or
ul#tabnav li:hover {
background: url('img/red-current-bg.png') center top no-repeat;
}