Bacteria usually live in densely packed communities called biofilms, where interactions between the bacteria give rise to complex properties. Quantitative analysis is indispensable in understanding those properties. However, current biofilm culturing approaches impose various limitations to these types of analysis. Here, we developed a microfluidic approach for quantitative study of biofilms, which is universal and can be used to culture biofilms of various bacterial species. To demonstrate the advantages of this approach, we present two examples, both of which revealed new biological insights. In the first example, we explored the response of Escherichia coli biofilms to exogenous hydrogen peroxide; We found the biofilms gained resistance to H2O2, but their growth was slowed down due to the metabolic cost of maintaining the resistance; However, under oxygen limitation, H2O2 can anti-intuitively boost biofilm growth. In the second example, we explored resource retention by Pseudomonas aeruginosa biofilms; We observed a fluorescent substance within the biofilm and identified it as the siderophore pyoverdine; We further showed that the extracellular matrix component Psl acted as a retention barrier for pyoverdine, minimizing its loss into the environment and therefore potentially promoting sharing of pyoverdine within the biofilm.