How about a borderless photo collection?

I've been attempting to create an image gallery for my portfolio, but I'm struggling to display the images without borders and arrange them both horizontally and vertically. So far, all of my efforts have been unsuccessful.

.portfolio {
  height: 1250px;
  width: 80%;
  margin: 0 auto;
  background-color: #CF9;
}
#thumbs {
  width: 20%;
  height: 50px;
  color: #090;
  float: left;
  font-size: 0px;
}
<div class="portfolio">
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
  <div id="thumbs">
    <a href="http">
      <img src="thumb.png">
    </a>
  </div>
</div>

is a website that demonstrates what I'm aiming for with my image gallery. However, in my case, all my images are the same size (though I would be open to exploring how to make them different sizes while still maintaining the desired layout).

Answer №1

It is crucial that element IDs are unique throughout your entire document. Having multiple elements with the same ID will render your HTML invalid, potentially leading to issues where your web page may not function as intended.

For further information on this topic, you can visit Can multiple different HTML elements have the same ID if they're different types?

To avoid these problems, I recommend utilizing classes instead. Classes allow for multiple elements to share the same identifier without causing conflicts.

Consider assigning all your elements a class of thumbs in place of an id. This way, you can use .thumbs in your CSS rules to style these elements consistently.

Answer №2

To start, the first issue that needs to be addressed is the id attribute. It's important not to reuse the same id in the HTML code.

Additionally, make sure to contain the a and img elements within the .thumb element for proper organization.

You can achieve this by implementing the following CSS:

.portfolio {
  height: 1250px;
  width: 80%;
  margin: 0 auto;
  background-color: #CF9;
}
.thumbs {
  width: 20%;
  color: #090;
  float: left;
  font-size: 0px;
}
.thumbs a {display:block;}
.thumbs img{width:100%;}
<div class="portfolio">
  <div class="thumbs">
    <a href="http">
      <img src="http://lorempixel.com/500/500/cats/1">
    </a>
  </div>
  <div class="thumbs">
    <a href="http">
      <img src="http://lorempixel.com/500/500/cats/2">
    </a>
  ...
</div>

Answer №3

To achieve a neat alignment of images without any margins, try completely eliminating the <div> tags and assigning the CLASS attribute of the <img> tag to thumbs. This will stack the images beautifully alongside each other thanks to the left float property. If there is no specific need for the <div> elements, it's best to remove them as they may disrupt the desired inline layout since they are block elements.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you guide me on implementing CSS Houdini in Next.js?

Exploring the world of CSS Houdini in my Next.js project has been quite an adventure. After successfully installing the necessary CSS Houdini package and css-paint-polyfill using yarn, I decided to follow the webpack guidelines provided at . Below is a sn ...

Uppercase the initial letter in a term to indicate a standard condition

I'm struggling to override the CSS in material UI. Even though I tried capitalizing both words, it only changes on selected and hover states, Is there a way to change it in the normal state as well? I've tried debugging but can't seem to fin ...

iCloud Web Portal - Element Search Failed: Element Not Found

Exploring Python as a novice, I embarked on a project that requires logging into Gmail and iCloud using Selenium. The Gmail portion went smoothly, indicating that I am headed in the right direction. However, I hit a roadblock while trying to identify the l ...

divs placed next to each other

I'm facing an issue with 4 divs within a parent div. I've used float:left in the style of all 4 divs to display them side by side. Although the divs are appearing next to each other, the height of the parent div is not adjusting to accommodate th ...

I'm having trouble getting the pasted HTML to work properly

I have been having some trouble with pasting an HTML table into my WordPress site using the Text Editor. I have styled the table with CSS and I have verified that both codes are correct. However, when I paste the table into WordPress or even use the W3Sch ...

There seems to be a glitch in my navigation bar - no matter what width I set, it still jumps around and acts funny

Check out my JSFiddle demonstration here: http://jsfiddle.net/nv78t/ I'm facing an issue where I want all list items to have a consistent width of 150px, but when I set it, the animation switches from left to right, which is not the desired effect. ...

Challenges with conflicting CSS styling issues

I am facing a CSS issue on my website. I am trying to add captions for images on my site. I have experimented with the jquery-capty plugin () and some custom CSS styles for framed images (). While both solutions work in my regular layout, they do not funct ...

Primeng is displaying multiple Confirmation Dialog boxes at once, causing me to receive more than one confirmation

I'm working on implementing a confirm dialog using primeng in my Angular web application. When I click the button that should trigger the method, the dialog pops up twice. To troubleshoot, I added a console log to see if the method is being called tw ...

What is the most effective way to reduce the spacing between columns in Bootstrap while maintaining consistent spacing on the outer edges?

I have set up my bootstrap columns as shown below: <div class="col-6"> <a href="gallerij/stockfotos/boeken" class="catphotowrap"> <div class="catphotodiv"> <img class=&quo ...

designing an uncomplicated button that incorporates the column size feature of Bootstrap

My concept involves crafting a minimalist green button with no text or border, just a sleek green shape that would automatically match the size of col-md-12 from Bootstrap. While I've come across similar inquiries, my limited understanding is hinderin ...

Transfer data between an HTML page and a PHP page hosted on separate locations using jQuery

Below is the code snippet I am currently working on: function send_data() { var a=$("#username").val(); var b=$("#password").val(); $.post("http://localhost/login/login.php", {uname: a, pswd: b}, function(data) { $("#result").html(data); }); ...

What is the process for creating a font file with Unicode support in three.js?

Exploring the use of three.js TextGeometry elements, I am experimenting with text that includes non-Latin characters like Cyrillic and Chinese glyphs using the Helvetiker font. Unfortunately, when rendered, the non-Latin characters are replaced with quest ...

Choose the desired options to add to the selection box

Here is a question that I have: <select class="myselect"> <option value="option 1">option 1</option> <option value="option 2">option 2</option> <option value="option 3">option 3</option> <option value="option 4 ...

Is it possible for me to select from H1-H6 tags depending on the font size?

Back in the day, I was coding before CSS even existed and we relied solely on HTML for page aesthetics. This background info will help explain my question. Is it incorrect to use different heading tags (h1 to h6) based on font size rather than significanc ...

Send the selected dropdown value to two separate PHP pages without using JavaScript

I am specifically looking for PHP programming, not JavaScript. My requirement is to have a dropdown menu containing 15 weeks. When a user selects a week from the dropdown, they should be redirected to a page that displays a message saying: Welcome! You h ...

"Adding a large amount of HTML using .append() is causing slow performance in Internet Explorer 10

Lately, I've been encountering some challenges with jQuery code in my workplace. Unfortunately, I don't have the exact code on hand at the moment, but I'll do my best to provide pseudo-code. Being relatively new to JavaScript, there may be e ...

issues with laravel blade form not redirecting to a specified route

I'm diving into named routing with Laravel 5.5 and encountering an odd issue while trying to handle a form action. Setups and Explanations: I defined my routes in web.php Route::post('questions/save_bulk', 'QuestionsController@sa ...

Enhance the appearance of Font Awesome stars by incorporating a hover effect

Is there a straightforward way to make them turn solid yellow when you hover over them? const styles = theme => ({ root: { flexGrow: 1, overflow: 'hidden', padding: theme.spacing(0, 3), }, paper: { maxWidth: 800, mar ...

When using Firefox to scale down a div with CSS `moz-transform`, the border details are unfortunately not retained

When viewing the following HTML in Firefox, you may notice that the right and bottom border is missing. However, Chrome and Internet Explorer display it correctly. Is this a bug in Firefox, or is there another method I can use to make it look consistent ...

Collapsing Bootstrap menu bar causing logo overlap

When the navbar collapses (when it shows the toggle icon), the menu items (home, services, portfolio, about, contact) overlap with the logo. If I remove the position:absolute from the logo (navbar-brand), the menu appears in the center. Is there a way to h ...