I have looked around at google and looked at another question: Page elements moving on window resize and I still cannot find the answer to this. My problem is that when I resize the browser my top div element where my navigation bar is moves messing up how the website looks. Since the CSS has it a certain amount to the right CSS probably updates how the page looks since I am resizing it. How would I keep the elements from moving upon page resizing?
My current code
<div id="top" style="background-image: url(images/Home/space.gif); height: 120px; width: 100%; border: 1px solid black;">
<a href="contact.html">
<img id="buttoncontact" alt="Contact" src="images\Logo\contact.png">
</a>
<a id="plugins" alt="Plugins" href="http://bukkit.org/" target="_blank"> +Bukkit</a>
<img id="bukkiticon" src="images\Logo\bukkit.png">
<a id="twitter" alt="Twitter" href="https://twitter.com/" target="_blank"> +Twitter</a>
<img id="twittericon" src="images\Logo\twitter.png">
<a id="youtube" alt="YouTube" href="https://www.youtube.com/" target="_blank"> +YouTube</a>
<img id="yticon" src="images\Logo\youtube.png">
<img id="td6img" src="images\Logo\TD6.png">
<nav id="navigation">
<a id="navigation-anchor-normal" href="contact.html">
<img src="images\Home\mars.png">
</a>
<a id="navigation-anchor-normal" href="projects.html">
<img src="images\Home\merc.png">
</a>
<a id="navigation-anchor-current" href="home.html">
<img src="images\Home\sun.png">
</a>
<a id="navigation-anchor-normal" href="lessons.html">
<img src="images\Home\nept.png">
</a>
<a id="navigation-anchor-normal" href="donate.html">
<img src="images\Home\jupiter.png">
</a>
</nav>
</div>
CSS
#top
{
background-image: url("images/Home/stars.png");
height: 95px;
border: 1px solid black;
width: 100%;
position: fixed;
top:0;
left:0;
background: rgba(255,255,255,1);
z-index: 100;
-webkit-box-shadow:0px 0px 20px rgba(44,44,44,.3);
}
#buttoncontact
{
float:left;
}
#yticon
{
position:absolute;
right:300px;
}
#youtube
{
text-decoration:none;
position:absolute;
right:225px;
color:red;
}
#twittericon
{
position:absolute;
right:190px;
}
#twitter
{
text-decoration:none;
position:absolute;
right:130px;
color:aqua;
}
#bukkiticon
{
position:absolute;
right:95px;
}
#plugins
{
text-decoration:none;
position:absolute;
right:35px;
color:#FF8000;
}
#navigation
{
text-align:center;
}
#navigation-anchor-normal
{
text-decoration:none;
color:aqua;
display:inline-block;
padding:5px 8px;
}
#navigation-anchor-current
{
text-decoration:none;
color:aqua;
display:inline-block;
padding:5px 8px;
}
The only element that is not moving is the TD6img above the nav. Everything else is moving when I resize the window.
What I want to accomplish is having these elements stay put upon resizing the window and not move with the resizing.
This is only happening to this div element no other div element that I have under it.
What you are trying to do is creating a responsive site.
I highly suggest you to use existing framework for that, and not trying to redo all by your self.
For that, look at twitter bootstrap that is the most robust and efficient jquery / javascript responsive design framework.
If you still want help with your task have a look at this DEMO Not sure if this is what you were looking for but play around with it if you want. Also you can upvote my answer when you get enough rep. I swithed most of your position:absolute to float:right
If you are looking for something easy to use and doesn't require a lot of changes, you can also use the "framework" from here: http://www.responsivegridsystem.com/
It is not too heavy and only gives you what you need to make a site responsive. I am using this for a company.
Twitter bootstrap in my opinion is good but it is heavy and although most classes doesn't get loaded, changing/modifying the code is very hectic.
Related
I've currently created a navigation bar for my website for university assignment. I've implemented an image on their which is the universities logo which I'd like to link to the university homepage. However, when I try to use the anchor tag '' to make the image clickable to link to the homepage, it messes up for the style of my navigation bar and would like to know if there's a workaround. I know the issue is that the image will take on the styles of the anchor tags I have declared for the navigation bar. I'll include images of before and after creating the link and show the HTML and CSS of that section.
This is the navbar before making the image clickable.
This is the HTML for it:
<div class="top_nav">
<img class="logo" src="images/NTU_badge.png" alt="NTU Badge">
<a class="active" href="#Home"> Home </a>
Hackathon
Choose a Challenge
Digital Horizons
</div>
This is the CSS for it:
.top_nav {
overflow: hidden;
background-color: #2c3e50;
border-bottom: 20px solid #ed0162;
position: fixed;
top: 0;
width: 100%;
}
.top_nav a {
float: left;
color: white;
text-align: center;
padding: 30px 20px;
text-decoration: none;
font-size: 17px;
margin-bottom: 0;
font-family: monospace;
}
.top_nav a:hover {
background-color: #ed0162;
color: white;
}
.logo {
float: left;
margin: 15px;
}
This is the HTML and webpage after I try to make the image clickable:
There is now big spacing inbetween and the hover style now affects the image when I don't want it too.
The HTML code after:
<header>
<div class="top_nav">
<a href="https://www.ntu.ac.uk/">
<img class="logo" src="images/NTU_badge.png" alt="NTU Badge">
</a>
<a class="active" href="#Home"> Home </a>
Hackathon
Choose a Challenge
Digital Horizons
</div>
</header>
I've tried removing the 'logo' class from the image style but it doesn't really change it that much.
There are lots of ways to do this but flexbox makes it really easy. also will simplify your css. Just wrap the image in a anchor tag to make it clickable.
.top_nav {
display:flex;
justify-content:space-around;
align-items:center;
overflow: hidden;
background-color: #2c3e50;
font-size:2vw;
width: 100%;
}
.top_nav a {
width:10%;
color: white;
text-decoration: none;
font-family: monospace;
}
.top_nav a:hover {
background-color: #ed0162;
color: white;
}
img{
width:100%;
}
#short{
width:2.5%;
}
<div class="top_nav">
<a id='short' href='https:\\www.google.com'><img class="fa facebook" src="https://www.sustainablewestonma.org/wp-content/uploads/2019/09/facebook-square-brands-blue.png" scale="0"></a>
<a class="active" href="#Home"> Home </a>
Hackathon
Choose a Challenge
Digital Horizons
</div>
I find that it's generally pretty poor practice to use element names (such as a and div) in CSS selectors at all, for this exact reason.
Consider adding something like class="navigation" to each link in your navbar, and then change the .top_nav a selector to .top_nav .navigation. Then you could add a similar class to the logo <a>.
Not only does this make the CSS more specific, but much more readable when someone else (or you in six months' time) has a look at this without any other context of the rest of the page.
One way to solve this is to use the :first-of-type pseudo css selector. Something like that would be the correct way to handle it:
.top_nav a:first-of-type {padding: 0;}
EDIT
I'm sorry, on the original answer i miss the part to advice you wrapping your image with a element. So change this:
<img class="logo" src="images/NTU_badge.png" alt="NTU Badge">
To:
<img class="logo" src="images/NTU_badge.png" alt="NTU Badge" />
I am a Beginner Website Developer, I want to make my college's project but stuck at the beginning because my navigation div and small divs in navigation div are not going to transform or transit at once. when i apply transition at one of em with absolute position all (also apply absolute position to other three small divs) the all three of em except first disappears. Code is linked. I want to make navigation just like IMDB's Navigation. (with downside transition and with links and picture at one end.)
-Thank in advance.
HTML CODE:
<body>
<div id="Papadiv">
<header id="Header">
<Div id="Logodiv">
<img src="Images/Logo.jpg" height="100px" width="100px" />
</Div>
<Div id="Titlediv">
<font size="+5" face="Comic Sans MS, cursive">MobilePassion.com</font>
</Div>
</header>
<nav id="Nav1">
<div id="navoption1">
<a href="Index.html">
New Arrivals</a>
</div>
<div id="navoption2">
<a href="Famousmodels.html">
Famous Models</a>
</div>
<div id="navoption3">
<a href="Whoweare.html">
Who We Are?</a>
</div>
<div id="navoption4">
<a href="Contactus.html">
Contact Us</a>
</div>
</nav>
/* CSS Document */
#Nav1
{
background-color: #FDAA2F;
height:50px;
width:800px;
}
#navoption1
{
background-color:#FD771E;
height:10px;
width:160px;
border-radius:20px;
float: left;
color:#722703;
padding:20px;
text-align:center;
}
#navoption2
{
background-color:#FD771E;
height:10px;
width:160px;
border-radius:20px;
float: left;
color:#722703;
padding:20px;
text-align:center;
}
#navoption3
{
background-color:#FD771E;
height:10px;
width:160px;
border-radius:20px;
float: left;
color:#722703;
padding:20px;
text-align:center;
}
#navoption4
{
background-color:#FD771E;
height:10px;
width:160px;
border-radius:20px;
float: left;
color:#722703;
padding:20px;
text-align:center;
#navoption1:hover
{
color:#C13D04;
background-color: #F5530E;
animation:alternate;
text-decoration:blink;
background-image:url(Rose%20(1).jpg)
}
#navoption2:hover
{
color:#C13D04;
background-color: #F5530E;
animation:alternate;
text-decoration:blink
}
#navoption3:hover
{
color:#C13D04;
background-color: #F5530E;
animation:alternate;
text-decoration:blink
}
#navoption4:hover
{
color:#C13D04;
background-color: #F5530E;
animation:alternate;
text-decoration:blink
}
I think first off you need to do some research on how to build a "CSS Mega Drop Down Menu". (That's usually what they are called and you should be able to find a good example in which you can structure your styling off of.)
A "classic" drop down menu usually contains lists nested (or in your case - divs) within parent list items.
"Here" is a good step by step example that I think should get you off and running.
I have been rtying to find a good resource for an example. These are good examples to learn from i think. http://code-tricks.com/simple-css-drop-down-menu/ , http://css-tricks.com/simple-jquery-dropdowns/ . It would also be wise for user experience to use hoverintent (http://cherne.net/brian/resources/jquery.hoverIntent.html) or a delay. This creates a better user experience.
I am using Joomla, Phoca Gallery Image Component and Phoca Callery module. It is not actaully the question about Joomla, but about CSS. Plugin creates gallery with 4 images. Those images should create 2 x 2 grid, using float:left.
Here is what I have as a result:
http://jsfiddle.net/qAx7c/ (original link: http://renathy.woano.lv/index.php/lv/par-mums-2)
.block {
border:1px solid #342e2b;
border-radius:7px;
padding: 12px 22px 12px 22px;
}
.block-box2 div.content-main {
width:50%;
display:inline-block;
float:left;
}
.block-box2 div.content-sidebar2 {
width:49.99%;
float:right;
}
/* float clearing for IE6 */
* html .clearfix{
height: 1%;
overflow: visible;
}
/* float clearing for IE7 */
*+html .clearfix{
min-height: 1%;
}
/* float clearing for everyone else */
.clearfix:after{
clear: both;
content: ".";
display: block;
height: 0;
visibility: hidden;
font-size: 0;
}
/* FIXes */
#phocagallery-module-ri .phocagallery-box-file {
padding: 0 !important;
background: none !important;
}
#phocagallery-module-ri .phocagallery-box-file-first {
background: none !important;
}
#phocagallery-module-ri {
margin-left: 40px !important;
}
#phocagallery-module-ri div.mosaic a img {
border: 1px solid #342e2b !important;
/*border: none !important;*/
}
#phocagallery-module-ri div.mosaic a img, #phocagallery-module-ri div.mosaic img {
-webkit-box-shadow: none !important;
box-shadow: none !important;
}
<div class="block block-box2 clearfix">
<div class="content-main">
<div class="item-page">
<h2>Par mums</h2>
Some text here
Some text here
</div>
</div>
<div class="content-sidebar2">
<div id="phocagallery-module-ri" style="text-align:center;">
<center style="padding:0px;margin:0px;">
<div class="mosaic" style="float:left;padding:5px;width:170px">
<a class="modal-button" title="Atmosfēra" href="">
<img src="phoca_thumb_m_parmums_telpas.jpg" alt="Atmosfēra" width="170" height="150">
</a>
</div>
<div class="mosaic" style="float:left;padding:5px;width:170px">
<a class="modal-button" title="Par mums" href="#">
<img src="phoca_thumb_m_parmums_atmosfera.jpg" alt="Par mums" width="170" height="149">
</a>
</div>
<div class="mosaic" style="float:left;padding:5px;width:170px">
<a class="modal-button" title="Par mums" href="#">
<img src="phoca_thumb_m_parmums_dzerieni.jpg" alt="Par mums" width="170" height="150">
</a>
</div>
<div class="mosaic" style="float:left;padding:5px;width:170px">
<a class="modal-button" title="Par mums ārpusē" href="#">
<img src="phoca_thumb_m_parmums_izskats.jpg" alt="Par mums ārpusē" width="170" height="150">
</a>
</div>
</center>
</div>
<div style="clear:both"></div>
</div>
As you see, one image is not floating correctly. The code of div phocagallery-module-ri is generated automatically.
I tried to change width, marings, paddings of images and divs, but nothing helps - one image is floating incorrectly, however it seems that everything should be fine.
Can you, please, give me some ideas, why this floating is broken?
The first image's code is :
<img src="/images/phocagallery/par_mums/thumbs/phoca_thumb_m_parmums_telpas.jpg" alt="Atmosfēra" width="170" height="150">
And the second image's code is :
<img src="/images/phocagallery/par_mums/thumbs/phoca_thumb_m_parmums_atmosfera.jpg" alt="Par mums" width="170" height="149">
They have different height ( 150 and 149 ), this is the reason.
Changing the second image's height to 150 will works fine.
The issue is that the second image is less tall than the first. Therefore, the second floats next to the first, but the third one also floats left to the first, leaving a gap. The fourth one doesn't fit next to the third, so it wraps to a new line.
So that's the cause. Now for the solution, I'm not a CSS professional, so I cannot say which of the following solutions is best, nor if there is another, better one.
One solution would be to embed each image in a container that has a fixed height, or at least has the same height for each of them.
Other possible solutions would be to use a CSS table way of styling.
Thirdly, adding a clear:both element after each second image (since you only want two on a row) will break the floating.
Given the nature of the site and the pictures in the gallery, you may also choose to make each thumbnail image the same size. That will also solve it, by taking away the trigger of the problem.
I'm designing a website. My monitor's resolution is 1280 x 1024 and I usually use Firefox for developing. This is how it looks and should look. This one is the correct one.
But there's a slight change when viewed in Chrome in the same monitor. Notice the right bottom corner.
Things get even worse when viewed in a another monitor with a different screen resolution. This is my screen at work which's resolution is 1366 x 768.
On Firefox
On Chrome
As you can see, the layout is messed up pretty bad. Below is the code.
HTML
<img id="yellowRing" src="images/about_rings/yellow_ring.png" />
<img id="magentaRing" src="images/about_rings/magenta_ring.png" />
<img id="blueRing" src="images/about_rings/blue_ring.png" />
<div id="aboutCaption">
<p>Our Team</p>
</div>
<div id="team">
<div class="member"><a data-member="one" href="#"><img src="images/team/one_thumbnail.png" /></a></div>
<div class="member"><a data-member="two" href="#"><img src="images/team/two_thumbnail.png" /></a></div>
<div class="member"><a data-member="three" href="#"><img src="images/team/three_thumbnail.png" /></a></div>
<div class="member"><a data-member="four" href="#"><img src="images/team/four_thumbnail.png" /></a></div>
</div>
CSS
#yellowRing {
position:absolute;
left:1200px;
bottom:-1300px;
z-index:2;
}
#magentaRing {
position:absolute;
left:1600px;
bottom:-1100px;
z-index:3;
}
#blueRing {
position:absolute;
left:2160px;
top:500px;
z-index:4;
}
#aboutCaption {
position:absolute;
left:2430px;
top:-50px;
z-index:4;
line-height:2.2em;
}
#aboutCaption p {
font-weight:lighter;
text-align:right;
color:#FFF;
font-size:55px;
}
#team {
position:absolute;
left:2135px;
top:90px;
width:432px;
height:110px;
z-index:4;
}
.member {
position:relative;
height:95px;
width:95px;
margin:8px 8px 8px 0px;
z-index:5;
display:inline-block;
}
.member:nth-child(1) {
margin-left:8px;
}
.member img {
height:95px;
width:95px;
}
This website only scrolls horizontally. My question is, why this is happening? And what should I do to make the layout consistent despite the screen size or the resolution? Or do I have to go about the responsive design and include multiple CSS files per benchmark?
Thank you.
To cover all platforms/browsers/etc... you will have to euther use a framework, which gets bulky, or if you're keeping it simple, I would go with some #media rules in order to cover your different layout dimensions. Basics of it can be found at W3 Media Types
I've been using the new CSS border-radius function for a while now, but I'm stumped today! I have a background image (120px x 60px) and have set a border radius of 5px, but it's only rounding the top two corners?!
The CSS code I'm using is here:
#buttonRow {
position:relative;
width:980px;
height:60px;
margin-left:51px;
margin-bottom:25px;
float:left;
}
#button {
position:relative;
float:left;
width:120px;
height:60px;
margin-left:25px;
padding-top:10px;
border-radius:5px;
background-image:url('../assets/buttons/generic_button.png');
background-repeat:no-repeat;
}
#singleLineButton {
position:relative;
float:left;
width:120px;
height:60px;
margin-left:25px;
padding-top:20px;
border-radius:5px;
background-image:url('../assets/buttons/generic_button.png');
background-repeat:no-repeat;
}
#buttonText {
width:120px;
height:auto;
color:#FFFFFF;
text-align:center;
font-size:16px;
font-family: Adobe Kaiti Std R;
}
And the output is this:
Why is it only showing the top corners as rounded?!
Any help would be greatly appreciated!
Thanks, Zulu
EDIT
Here is the HTML for those asking:
<div id="buttonRow">
<a href="http://www.zuluirminger.com/SchoolAdmin/individual_table_management.php">
<div id="button"><div id="buttonText">Individual Table Management</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/attendance_index.php">
<div id="singleLineButton"><div id="buttonText">Attendance</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/school_members.php">
<div id="singleLineButton"><div id="buttonText">School Members</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/search_choice.php">
<div id="singleLineButton"><div id="buttonText">Search</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/school_details.php">
<div id="singleLineButton"><div id="buttonText">School Details</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/user_management.php">
<div id="singleLineButton"><div id="buttonText">Users</div></div>
</a>
</div>
It might be that your image isn't long enough and thus you don't see the rounded corners on the bottom. I ran into that today, actually.
I simply set a background color and it showed me what the issue was. So, just modify your CSS to:
background-image: #00ff00 url('../assets/buttons/generic_button.png');
or:
background-color: #00ff00; /* bright green for contrast */
background-image: url('../assets/buttons/generic_button.png');
That will at least tell you if your image covers the whole area or not and you will know what to do from there.
In CSS3 it's done like this:
border-top-right-radius: 8px;
border-top-left-radius: 8px
Most likely the bottoms are getting cut off from overflow. Make sure the containing element is tall enough to accomodate the heights of these or set the all the ancestor's overflow to overflow: visible.
Also, use jsfiddle.net to post live examples instead of just the CSS in a vacuum. CSS requires context.
As previously answered, your image isn't large enough. Your div is 120x60px to match your image, but you have a padding-top of 10px, which extends the size of the div to 120x70px total--too large to show the rounding. Either change the size of your background image or resize the div to 50px tall--with padding, it'll end up at the proper size.
You can use this code
#buttonRow {
width: 1170px;
margin: 0 auto;
display: block;
}
#button {
position:relative;
float:left;
width:120px;
height:60px;
margin-left:25px;
padding-top:10px;
border-radius: 5px;
background-image:url('../assets/buttons/generic_button.png');
background-repeat:no-repeat;
background: red;
}
#singleLineButton {
position:relative;
float:left;
width:120px;
height:60px;
margin-left:25px;
padding-top:20px;
border-radius: 5px;
background-image:url('../assets/buttons/generic_button.png');
background-repeat:no-repeat;
background: red;
}
#buttonText {
width:120px;
height:auto;
color:#FFFFFF;
text-align:center;
font-size:16px;
font-family: Adobe Kaiti Std R;
}
<div id="buttonRow">
<a href="http://www.zuluirminger.com/SchoolAdmin/individual_table_management.php">
<div id="button"><div id="buttonText">Individual Table Management</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/attendance_index.php">
<div id="singleLineButton"><div id="buttonText">Attendance</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/school_members.php">
<div id="singleLineButton"><div id="buttonText">School Members</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/search_choice.php">
<div id="singleLineButton"><div id="buttonText">Search</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/school_details.php">
<div id="singleLineButton"><div id="buttonText">School Details</div></div>
</a>
<a href="http://www.zuluirminger.com/SchoolAdmin/user_management.php">
<div id="singleLineButton"><div id="buttonText">Users</div></div>
</a>
</div>
Try using margin-top instead of padding top, I've had this issue recently and that seemed to fix it.